Given
- a plane $p\in\mathbb{P}^3$ expressed in homogeneous coordinates ($p_x$, $p_y$, $p_z$, $p_w$)
- a ray expressed as
- a source point $s\in\mathbb{P^3}$ expressed in homogeneous coordinates ($s_x$, $s_y$, $s_z$, $s_w$)
- a direction $d\in S^2$ expressed in coordinates ($d_x$, $d_y$, $d_z$)
how can I find the point at which the ray intersects the plane?
I can sometimes work out efficient algorithms with cross products in $\mathbb{P^2}$ but I battle with $\mathbb{P^3}$ due to having to visualize 4 dimensions.
One way to represent a line in $\mathbb P^3$ is via its Plücker matrix: if $\mathbf p$ and $\mathbf q$ are two distinct points on the line, then its Plücker matrix is $L=\mathbf p\mathbf q^T-\mathbf q\mathbf p^T$. It’s an easy exercise to verify that $L$ is, up to a scale factor, independent of the choice of the two points. A handy feature of this representation is that if $\mathbf\pi$ is a homogeneous vector that represents a plane, its intersection with the line is simply $L\mathbf\pi$.
Applying this to your problem, you have the two points $\mathbf s = (s_x,s_y,s_z,s_w)^T$ and $\mathbf d = (d_x,d_y,d_z,0)^T$ that define the line, and the plane $\mathbf\pi = (p_x,p_y,p_z,p_w)^T$, so $$L\mathbf\pi = (\mathbf s\mathbf d^T-\mathbf d\mathbf s^T)\mathbf\pi = (\mathbf\pi^T\mathbf d)\mathbf s - (\mathbf\pi^T\mathbf s)\mathbf d,\tag{*}$$ i.e., two dot products, two multiplications of a vector by a scalar, a vector addition, and three divisions to dehomogenize. If this expression vanishes, then the line lies on the plane. If you’re specifically interested in the intersection of a ray with the plane, you’ll also need to test that this point lies on the correct side of the line from $s$, or equivalently, that $d$ points toward the plane from $s$.
The expression (*) can also be derived directly: The line through $\mathbf s$ and $\mathbf d$ consists of all nontrivial linear combinations $\lambda\mathbf s+\mu\mathbf d$ of the two points, and the intersection of the line with $\mathbf\pi$ can therefore be found by solving $$\mathbf\pi^T(\lambda\mathbf s+\mu\mathbf d) = \begin{bmatrix}\mathbf\pi^T\mathbf s&\mathbf\pi^T\mathbf d\end{bmatrix} \begin{bmatrix}\lambda\\\mu\end{bmatrix}=0$$ for $\lambda$ and $\mu$, which is obviously satisfied by $\lambda=\mathbf\pi^T\mathbf d$, $\mu=-\mathbf\pi^T\mathbf s$. It can also be viewed as a special case of a principle known as Plücker’s mu.
The formula (*) is the three-dimensional analogue of using cross products to find the intersection of the line $\mathbf l$ with the line defined by $\mathbf s$ and $\mathbf d$ in $\mathbb P^2$, since we have the identity $$\mathbf l\times(\mathbf s\times\mathbf d) = (\mathbf l^T\mathbf d)\mathbf s - (\mathbf l^T\mathbf s)\mathbf d.$$