Page 1 of 1

Offset Plane?

Posted: Tue Feb 18, 2020 8:53 pm
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

Re: Offset Plane?

Posted: Tue Feb 18, 2020 9:18 pm
by Samuel
NewPosition = OldPosition + Distance * NormalizedVector

Re: Offset Plane?

Posted: Wed Feb 19, 2020 12:46 am
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]

Re: Offset Plane?

Posted: Wed Feb 19, 2020 1:16 am
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

Re: Offset Plane?

Posted: Wed Feb 19, 2020 1:28 am
by IdeasVacuum
...ah yes, that's it thanks!