In analytic geometry, the intersection of a line and a plane in three-dimensional space can be the empty set, a point, or a line. It is the entire line if that line is embedded in the plane, and is the empty set if the line is parallel to the plane but outside it. Otherwise, the line cuts through the plane at a single point.
Distinguishing these cases, and determining equations for the point and line in the latter cases, have use in computer graphics, motion planning, and collision detection.
In vector notation, a plane can be expressed as the set of points
p
(p-p0) ⋅ n |
=0
n
p0 |
a ⋅ b
a
b
The vector equation for a line is
p=
l0 |
+l d d\inR
l
l0 |
d
((l0 |
+l d)-
p0) ⋅ n |
=0.
(l ⋅ n) d+
(l0-p0) ⋅ n |
=0.
d
d=
{(p0-l0) ⋅ n |
\overl ⋅ n
If
l ⋅ n=0
(p0-l0) ⋅ n |
=0
If
l ⋅ n\ne0
d
p
p=
l0 |
+l d
A line is described by all points that are a given direction from a point. A general point on a line passing through points
la=(xa,ya,za)
lb=(xb,yb,zb)
la+labt, t\inR,
where
lab=lb-la
la
lb
Similarly a general point on a plane determined by the triangle defined by the points
p0=(x0,y0,z0)
p1=(x1,y1,z1)
p2=(x2,y2,z2)
p0+p0u+p0v, u,v\inR,
where
p0=p1-p0
p0
p1
p0=p2-p0
p0
p2
The point at which the line intersects the plane is therefore described by setting the point on the line equal to the point on the plane, giving the parametric equation:
la+labt=p0+p0u+p0v.
la-p0=-labt+p0u+p0v,
\begin{bmatrix}la-p0\end{bmatrix}=\begin{bmatrix}-lab&p0&p0\end{bmatrix}\begin{bmatrix}t\ u\ v\end{bmatrix},
This produces a system of linear equations which can be solved for
t
u
v
t\in[0,1],
la
lb
u,v\in[0,1],
p0
p0
p0
(u+v)\leq1
p0
p1
p2
The determinant of the matrix can be calculated as
\det(\begin{bmatrix}-lab&p0&p0\end{bmatrix})=-lab ⋅ (p0 x p0).
If the determinant is zero, then there is no unique solution; the line is either in the plane or parallel to it.
If a unique solution exists (determinant is not 0), then it can be found by inverting the matrix and rearranging:
\begin{bmatrix}t\ u\ v\end{bmatrix}=\begin{bmatrix}-lab&p0&p0\end{bmatrix}-1\begin{bmatrix}la-p0\end{bmatrix},
\begin{bmatrix}t\ u\ v\end{bmatrix}=
1 | |
-lab ⋅ (p0 x p0) |
\begin{bmatrix}{(p0 x p0)}T\ {(p0 x -lab)}T\ {(-lab x p0)}T\end{bmatrix}\begin{bmatrix}la-p0\end{bmatrix}
\begin{bmatrix}t\ u\ v\end{bmatrix}=
1 | |
-lab ⋅ (p0 x p0) |
\begin{bmatrix}{(p0 x p0)} ⋅ (la-p0)\ {(p0 x -lab)} ⋅ (la-p0)\ {(-lab x p0)} ⋅ (la-p0)\end{bmatrix},
t=
{(p0 x p0) | |
⋅ |
(la-p0)}{-lab ⋅ (p0 x p0)}
u=
{(p0 x -lab) | |
⋅ |
(la-p0)}{-lab ⋅ (p0 x p0)}
v=
{(-lab x p0) | |
⋅ |
(la-p0)}{-lab ⋅ (p0 x p0)}.
la+labt
In the ray tracing method of computer graphics a surface can be represented as a set of pieces of planes. The intersection of a ray of light with each plane is used to produce an image of the surface. In vision-based 3D reconstruction, a subfield of computer vision, depth values are commonly measured by so-called triangulation method, which finds the intersection between light plane and ray reflected toward camera.
The algorithm can be generalised to cover intersection with other planar figures, in particular, the intersection of a polyhedron with a line.