View Full Version : Take two points, make a perpendicular plane?
09-15-2008, 06:07 PM
This one is beyond me, maybe someone can help.
I need to figure out a way to take any two points in 3D space, and create a plane perpendicular to the line that runs between the two points.
Basically, with results like so:
Using the " - " characters as the line between the points, and " I " as the plane.
I realize that with only two points, there is no way to control the direction of the resulting plane along its "spin" axis, but that isn't relevant to my needs. I only need to be able to measure distances from the surface of that plane, which will be the same no matter what direction it is spun around in.
I don't even know what kind of math would be involved in this, let alone how I would implement it in MAXScript. Please help!
Let's say that the points are A and B.
Then the vector C you need is C=normalize (B-A).
Call (MatrixFromNormal C) and assign the resulting matrix3 to the .transform property of your plane. MatrixFromNormal takes one vector and uses it as the Z axis of a matrix. The X and Y are selected based on rules described in Reference, but you don't really care for them.
Then center the position at the middle point between A and B.
Or in short,
thePlane = plane transform:(matrixFromNormal (normalize (B-A))) pos:((A+B)/2)
Alternatively, you could build your own matrix using your own UP vector and a couple of cross products as shown in the MAXScript Reference > How do I align the UVW_Modifier's Gizmo to a selected face? topic.
(In other words, buy my "The Matrix : Explained" DVD ;))
09-16-2008, 04:19 PM
Alternatively, you could build your own matrix
If I build my own matrix, can I run on the walls in it? :D
Actually, I do have your Matrix Explained DVD. I got it as a Christmas present (my friends and family say I am SO much fun to shop for :rolleyes: ) Been a while since I looked at it though. I am clearly due for a refresher.
09-18-2008, 04:11 AM
Worked like a charm, thanks! Incidentally, here is the final script. More a toy than anything really practical, but there may be something useful in it for someone.
rollout RO_AxisPlane "Axis Plane"
local objectA, objectB
fn createPlane =
obj1 = objectA
obj2 = objectB
pos1 = obj1.pos
pos2 = obj2.pos
min1 = obj1.min
max1 = obj1.max
min2 = obj2.min
max2 = obj2.max
len1 = max1.Z - min1.Z
wid1 = max1.X - min1.X
hgt1 = max1.Y - min1.Y
len2 = max2.Z - min2.Z
wid2 = max2.X - min2.X
hgt2 = max2.Y - min2.Y
array_Dim = #(len1, wid1, hgt1, len2, wid2, hgt2)
maxDim = amax array_Dim
planeTrans = (matrixFromNormal (normalize (pos2 - pos1)))
planePos = ((pos1 + pos2) / 2)
thePlane = plane transform:planeTrans pos:planePos \
length:(maxDim * sqrt(2)) width:(maxDim * sqrt(2)) \
fn filterGeometry obj = (superClassOf obj == geometryClass)
pickbutton pck_A "Select object A" autoDisplay:true filter:filterGeometry
pickbutton pck_B "Select object B" autoDisplay:true filter:filterGeometry
button btn_CreatePlane "Create Axis Plane" enabled:false
on pck_A picked obj do
objectA = obj
if (isValidNode objectB) and (objectB != undefined) do btn_createPlane.enabled = true
on pck_B picked obj do
objectB = obj
if (isValidNode objectA) and (objectA != undefined) do btn_createPlane.enabled = true
on btn_CreatePlane pressed do (createPlane())
createDialog RO_AxisPlane width:220
09-18-2008, 04:11 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.