## How Do You Tell Whether Two Lines Intersect in 3D?

How do you tell whether two three-dimensional lines intersect?  My colleague Greg Elliott in physics asked me this recently.  He understood how the usual method works, but he wanted to know whether there was a more clever method.  In this post I’ll discuss the usual method and the alternative method I first suggested and that we refined.  (I’ll leave it to the reader to determine whether the second method is “more clever.”)  This post also assumes that you know that the lines aren’t parallel.

To see how the methods work, let’s look at an example.  Do the lines $(t, -2+3t, 4-t)$ and $(2s, 3+s, -3+4s)$ intersect?

Method 1:  The usual method is to set the components equal to each other and see whether there is a solution.  This gives the system

\displaystyle \begin{aligned} t &= 2s \\ -2+3t &= 3+s \\ 4-t &= -3+4s \end{aligned}

Substituting the first equation into the second yields $-2+3(2s) = 3+s \implies s = 1$.  Substituting the first equation into the third yields $4-(2s) = -3+4s \implies s = 7/6$.  Since s cannot take on both values, the lines do not intersect.  (If we had gotten the same value for s then the lines would intersect.)

Method 2: Two lines intersect if they lie in the same plane.  Thus, first construct the plane defined by the first line and the direction vector for the second line.  Then see if the second line lies in this plane.  To construct the plane, take the direction vectors for the two lines: ${\bf u} = \langle 1, 3, -1 \rangle$ and ${\bf v} = \langle 2, 1, 4 \rangle$.  Then cross them to get the vector ${\bf w} = \langle 13, -6, -5 \rangle$.  A plane needs a point and a normal vector.  Take any point from the first line; the simplest is probably $(0, -2, 4)$.  The equation for the plane defined by the first line and v is thus $13x - 6(y+2) - 5(z-4) = 0$.  Now, if the second line lies in this plane then any point from that line will satisfy the plane equation.  Substituting in the point $(0, 3, -3)$ from the second line yields $0 - 6(3+2) - 5(-3-4) = -30+35 = 5 \neq 0$.  Thus the second line lies in a different plane, and the two lines do not intersect.

(Formula for Method 2).  Generalizing from this example, we can give an explicit condition in terms of a formula.   A line in 3D is defined by a point p and a director vector u.  Let the second line be defined by point q and direction vector v.  Take the two direction vectors u and v and cross them to get vector ${\bf u} \times {\bf v}$.  Then take the displacement vector ${\bf p} - {\bf q}$ between the two points.  Since ${\bf u} \times {\bf v}$ is orthogonal to the plane defined by the direction vectors, the only way the two lines lie in the same plane is if ${\bf u} \times {\bf v}$ is orthogonal to the displacement vector ${\bf p} - {\bf q}$.  In other words, the two lines lie in the same plane if and only if $({\bf u} \times {\bf v}) \cdot ({\bf p} - {\bf q}) = 0$.