[Math] Calculating if a line intersects a plane

geometry

I'd just like to check that I'm doing this correctly.

Given three points $Q, R, S$ to define a plane:

$ QR = ( R_x – Q_x , R_x – Q_x , R_x – Q_x ) $

$ QS = ( S_x – Q_x , S_x – Q_x , S_x – Q_x ) $

We then do cross product on $QR$ and $QS$ to get $N$, which is a vector perpendicular to the plane.

This gives the equation of the plane as:

$ N_x(x-Q_x)+N_y(y-Q_y)+N_z(z-Q_z) = 0 $

We are then given two points $A, B$ to define a line

This can then be broken down into three parts:

$ x = A_x+(B_x-A_x)*t $

$ y = A_y+(B_y-A_y)*t $

$ z = A_z+(B_z-A_z)*t $

We can then substitute this into the plane equation to solve the plane for $t$.

Once we have $t$ we simply substitute it into the above equations to get the point of collision.

If it is not possible to solve for T, then there are either infinite collisions or no collisions.

Is all that correct or have I missed a step?

Best Answer

What you wrote looks right.

There are some special cases that might be worth considering, depending on your application. For example, if $Q,R,S$ are collinear, they don't define a unique plane. In that case the cross product $N$ will turn out to be the null vector, and therefore any point in space would seem to lie on this plane. That's because any point in space does lie on one plane together with $Q,R,S$, as there always is at least one plane though a given line and a given point.

Even more obviously, if $A$ and $B$ were to be the same point, you'd not have a well-defined line. This time you likely won't be able to find any $t$ to satisfy your equation. But there still would be lines throuh $A$ and $B$ which intersect the plane.

If your plane is indeed defined by three non-collinear points, and your line is defined by two distinct points, then you can either compute the intersection as you wrote, or you can conclude that the line lies within the plane or parallel to the plane. In ther former case, $A$ and $B$ will lie within the plane, while in the latter case, neither does, so you can use this to distinguish the cases.

Coming from a background of projective geometry, I can't avoid mentioning that there are other approaches, e.g. using Grassmann-Plücker coordinates, but I'll not go into details on this here.

Related Question