Offset Plane?

Everything related to 3D programming
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Offset Plane?

Post by IdeasVacuum »

I would like to be able to define an Offset Plane (A plane parallel to another plane, a given distance from it). The planes I'm using are all defined as a Normal Vector and a point on the plane, V0. So the distance would be measured along the plane normal.
Image
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 755
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Offset Plane?

Post by Samuel »

NewPosition = OldPosition + Distance * NormalizedVector
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Offset Plane?

Post by IdeasVacuum »

Hi Samuel

How does that actually work?

Code: Select all

EnableExplicit

Structure pt3d
x.d
y.d
z.d
EndStructure

Structure vector3d
x.d
y.d
z.d
EndStructure

Structure plane3d
VecNorm.vector3d
PtV0.pt3d
EndStructure

Global OrgPlane.plane3d
Global OffPlane.plane3d
Global dOffset.d


Procedure OffsetPlane(*OffsetPlane.plane3d, *OrginalPlane.plane3d, dOffset.d)
;#---------------------------------------------------------------------------

               *OffsetPlane\VecNorm\x = *OrginalPlane\VecNorm\x
               *OffsetPlane\VecNorm\y = *OrginalPlane\VecNorm\y
               *OffsetPlane\VecNorm\z = *OrginalPlane\VecNorm\z
                  *OffsetPlane\PtV0\x = (*OrginalPlane\PtV0\x + dOffset) * *OrginalPlane\VecNorm\x
                  *OffsetPlane\PtV0\y = (*OrginalPlane\PtV0\y + dOffset) * *OrginalPlane\VecNorm\y
                  *OffsetPlane\PtV0\z = (*OrginalPlane\PtV0\z + dOffset) * *OrginalPlane\VecNorm\z
EndProcedure


         OrgPlane\VecNorm\x = 0.000000
         OrgPlane\VecNorm\y = -0.693439
         OrgPlane\VecNorm\z = 0.720515
            OrgPlane\PtV0\x = 2.007707
            OrgPlane\PtV0\y = -19.221010
            OrgPlane\PtV0\z = 13.384741

                    dOffset = 11.55

         OffsetPlane(OffPlane, OrgPlane, dOffset)

         Debug "OffPlane\VecNorm\x = " + StrD(OffPlane\VecNorm\x, 6)
         Debug "OffPlane\VecNorm\y = " + StrD(OffPlane\VecNorm\y, 6)
         Debug "OffPlane\VecNorm\z = " + StrD(OffPlane\VecNorm\z, 6)
         Debug "   OffPlane\PtV0\x = " + StrD(OffPlane\PtV0\x, 6)
         Debug "   OffPlane\PtV0\y = " + StrD(OffPlane\PtV0\y, 6)
         Debug "   OffPlane\PtV0\z = " + StrD(OffPlane\PtV0\z, 6)
[/size]
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 755
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Offset Plane?

Post by Samuel »

You need to get rid of the parenthesis in your procedure because the multiplication of the distance and normal vector has to happen first.

Try this.

Code: Select all

*OffsetPlane\PtV0\x = *OrginalPlane\PtV0\x + dOffset * *OrginalPlane\VecNorm\x
*OffsetPlane\PtV0\y = *OrginalPlane\PtV0\y + dOffset * *OrginalPlane\VecNorm\y
*OffsetPlane\PtV0\z = *OrginalPlane\PtV0\z + dOffset * *OrginalPlane\VecNorm\z
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Offset Plane?

Post by IdeasVacuum »

...ah yes, that's it thanks!
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply