Hello Pixel!
This is actually a little harder than it seems, but not impossible ;>
from mathworld:
http://mathworld.wolfram.com/Line-PlaneIntersection.html
but, luckily for us Max comes with all sorts of funky things for finding this kind of stuff out so why do we need to get too complicated!! :
(
planeNormal=[0,0,1]
planePoint=[1,2,3]
lineVector=[0,0,-1]
linePoint=[2,4,9]
p=plane pos:planepoint dir:planenormal -- create a plane for our intersection
converttomesh p -- turn it into a mesh for our intersectray
r=ray linepoint linevector -- cast the ray
i=(intersectray p r) -- find the intersection
if i!=undefined then h=point pos:i.pos dir:i.dir -- if there is an intersection, place a marker!
-- make a spline between our two points
spl=splineshape pos:[0,0,0]
s=addnewspline spl
addknot spl s #corner #line linePoint
addknot spl s #corner #line (linePoint+lineVector)
updateshape spl
)
This is only going to work in certain circumstances, for example the lpane is ony so large! so maybe maths is a better way to go after all:
n=[0,0,1] -- planeNormal
c=[1,2,3] -- planePoint
v=[0,0,-1] -- lineVector
a=[2,4,9] -- linePoint
b=a+v -- turn our line pos and vector into a second point b
-- t is the missing part of our equation, and is calculated by dividing the dot product of
-- the plane point and the start point, and the end point and the start point.
t=(dot (c-a) n) / (dot (b-a) n)
-- now we can calculate the intersection point.
r=a+t*(b-a)
-- the intersection point!
p=point pos:r
-- make a plane and a shape to test visually:
-- the plane:
p=plane pos:c dir:n
-- the vector:
spl=splineshape pos:[0,0,0]
s=addnewspline spl
addknot spl s #corner #line a
addknot spl s #corner #line b
updateshape spl
Hope this helps!
Josh.