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 and 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
Substituting the first equation into the second yields . Substituting the first equation into the third yields . 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: and . Then cross them to get the vector . A plane needs a point and a normal vector. Take any point from the first line; the simplest is probably . The equation for the plane defined by the first line and v is thus . Now, if the second line lies in this plane then any point from that line will satisfy the plane equation. Substituting in the point from the second line yields . 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 . Then take the displacement vector between the two points. Since is orthogonal to the plane defined by the direction vectors, the only way the two lines lie in the same plane is if is orthogonal to the displacement vector . In other words, the two lines lie in the same plane if and only if .