Line–plane intersection explained

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.

Algebraic form

In vector notation, a plane can be expressed as the set of points

p

for which
(p-p0)n

=0

where

n

is a normal vector to the plane and
p0
is a point on the plane. (The notation

ab

denotes the dot product of the vectors

a

and

b

.)

The vector equation for a line is

p=

l0

+ldd\inR

where

l

is a unit vector in the direction of the line,
l0
is a point on the line, and

d

is a scalar in the real number domain. Substituting the equation for the line into the equation for the plane gives
((l0

+ld)-

p0)n

=0.

Expanding gives

(ln)d+

(l0-p0)n

=0.

And solving for

d

gives

d=

{(p0-l0)n

\overln

}.

If

ln=0

then the line and plane are parallel. There will be two cases: if
(p0-l0)n

=0

then the line is contained in the plane, that is, the line intersects the plane at each point of the line. Otherwise, the line and plane have no intersection.

If

ln\ne0

there is a single point of intersection. The value of

d

can be calculated and the point of intersection,

p

, is given by

p=

l0

+ld

.

Parametric form

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)

and

lb=(xb,yb,zb)

can be represented as

la+labt,t\inR,

where

lab=lb-la

is the vector pointing from

la

to

lb

.

Similarly a general point on a plane determined by the triangle defined by the points

p0=(x0,y0,z0)

,

p1=(x1,y1,z1)

and

p2=(x2,y2,z2)

can be represented as

p0+p0u+p0v,u,v\inR,

where

p0=p1-p0

is the vector pointing from

p0

to

p1

, and

p0=p2-p0

is the vector pointing from

p0

to

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.

This can be rewritten as

la-p0=-labt+p0u+p0v,

which can be expressed in matrix form as

\begin{bmatrix}la-p0\end{bmatrix}=\begin{bmatrix}-lab&p0&p0\end{bmatrix}\begin{bmatrix}t\u\v\end{bmatrix},

where the vectors are written as column vectors.

This produces a system of linear equations which can be solved for

t

,

u

and

v

. If the solution satisfies the condition

t\in[0,1],

, then the intersection point is on the line segment between

la

and

lb

, otherwise it is elsewhere on the line. Likewise, if the solution satisfies

u,v\in[0,1],

, then the intersection point is in the parallelogram formed by the point

p0

and vectors

p0

and

p0

. If the solution additionally satisfies

(u+v)\leq1

, then the intersection point lies in the triangle formed by the three points

p0

,

p1

and

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},

which expands to

\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}

and then to

\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},

thus giving the solutions:

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)}.

The point of intersection is then equal to

la+labt

Uses

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.

See also

External links

References