Determining plane intersection with a ray Say I know the starting point $P$ and the direction vector $\vec{D}$ of a ray and, and I have a plane specified by a normal vector and a point in the plane $X$. under what conditions can I be certain the ray will intersect the plane? I believe it comes down to the sign of the dot product between $\vec{D}$ and some vector which specifies the plane, but I'm unsure of the specific details, nor how $P$ fits into this. Would someone kindly help me clear this up?
 A: The intersection $Q$ lies on the plane, which means
$$
\vec{N}\cdot Q = \vec{N}\cdot X
$$
and it is part of the ray, which means
$$
Q=P + \lambda \vec{D} \;\;\text{for some}\;\; \lambda \geq 0
$$
Now insert one into the other and you get
$$
\vec{N}\cdot P+\lambda\,\left(\vec{N}\cdot \vec{D}\right) = \vec{N}\cdot X
$$
or
$$
\lambda =\frac {\vec{N}\cdot (X-P)}{\vec{N}\cdot \vec{D}}
$$
If $\lambda$ is positive, then the intersection is on the ray. If it is negative, then the ray points away from the plane. If it is $0$, then your starting point is part of the plane.
If $\vec{N}\cdot \vec{D} = 0,$ then the ray lies on the plane (if $\vec{N}\cdot (X-P)=0$) or it is parallel to the plane with no intersection at all (if $\vec{N}\cdot (X-P)\neq 0$).
As you can see, you do not even have to calculate $\lambda.$ It is sufficient to know the signs of $\vec{N}\cdot (X-P)$ and $\vec{N}\cdot \vec{D}.$
Edit
Let $a = \vec{N}\cdot (X-P)$ and $b = \vec{N}\cdot \vec{D}$. Then
\begin{array}{c|c|c|c}
 & a<0 & a=0 & a>0 \\
\hline 
b<0 & \text{ray points towards} & P \text{ on plane} &  \text{ray points away from} \\
 & \text{plane, intersection} &   &  \text{plane, no intersection} \\
\hline 
b=0 & \text{ray and plane parallel,} & \text{ray on plane} &  \text{ray and plane parallel,} \\
    & \text{no intersection} &  &  \text{no intersection} \\
\hline 
b>0 & \text{ray points away from}  &  P \text{ on plane} &  \text{ray points towards} \\
 & \text{plane, no intersection}  & &  \text{plane, intersection}
\end{array}
