Notifications
Clear all
[Closed] Create plane between 2 points
Jul 14, 2010 11:01 am
I’m looking for a way to create a plane between 2 points.
First point is top left corner of the plane and the second is the bottom right corner. The only rotation of the plane should be the Z rotation.
I hope someone can point me in the right direction.
3 Replies
Jul 14, 2010 11:01 am
Bottom left corner verts position is [Point1.x, Point1.y, Point2.z]
Top right corner is [Point 2.x, Point2.y, Point1.z]
So there you have your 4 points for your face.
Jul 14, 2010 11:01 am
Heh, and here I was expecting some complicated math to get this to work.
Excellent, thanks a lot!
Jul 14, 2010 11:01 am
Just in case anyone else needs it:
-- The 2 points
pnt1 = [5.5,-4.0,3.0]
pnt2 = [7.5,-6.0,0]
fn createPlane p1 p2 =
(
-- Get all 4 points
topleft = p1
bottomright = p2
topright = [bottomright.x, bottomright.y, topleft.z]
bottomleft = [topleft.x, topleft.y, bottomright.z]
-- Get plane width and length
pWidth = distance topleft topright
pLength = distance topleft bottomleft
-- Get the rotation
x=normalize (topright - topleft)
z=[0,0,1]
y=normalize (cross z x)
pTransform = (matrix3 x y z topleft)
-- Create the Plane
thePlane = Plane()
thePlane.name = uniqueName "theplane_"
-- Rotate the Plane to set it upright
thePlane.dir = [0,-1,0]
ResetTransform thePlane
-- Set width and length of the Plane
thePlane.width = pWidth
thePlane.length = pLength
-- Set pivot to topleft corner
thePlane.pivot.x = thePlane.min.x
thePlane.pivot.z = thePlane.max.z
-- Position and rotate the Plane
thePlane.transform = pTransform
)
createPlane pnt1 pnt2