How to Find the Shortest Distance Between Two Parallel Lines in 3D
At a glance
- 1. Choose points
Pick one point on each line and identify a nonzero direction vector shared by both lines.
- 2. Find the separation
Subtract the point coordinates to get a vector connecting the two chosen points.
- 3. Take the cross product
Cross the separation vector with the direction vector, then find the cross product's magnitude.
- 4. Divide by direction length
Divide that magnitude by the direction vector's magnitude to get the shortest distance.
To find the shortest distance between two parallel lines in three-dimensional space, compare points on the lines in the direction perpendicular to both. The points need not be chosen specially: a cross product removes the component of their separation that runs along the lines.
The distance formula
Write the two lines using points and and a shared nonzero direction vector :
Here and range over all real numbers. The shortest distance is
The cross product’s magnitude is the area of the parallelogram formed by and . Dividing that area by the length of the base, , gives the parallelogram’s height. That height is exactly the perpendicular separation between the lines.
The direction vectors in the lines’ equations do not have to be written identically. If they are parallel, one is a nonzero scalar multiple of the other, so you can use either as . The formula is unchanged if you scale by a nonzero number.
Why the formula gives the minimum
Let . A point on the second line minus a point on the first is
As you move along the lines, the value of can be any real number. This changes only the component parallel to ; the component of perpendicular to stays the same. The smallest possible separation occurs when the parallel component has been canceled.
The perpendicular component of is minus its projection onto . Its length is therefore
The cross-product identity shows that this is the same as .
Worked example
Consider the lines
Their direction vectors are parallel because . Choose , , and . The vector between the selected points is
Compute the cross product and the direction-vector length:
So the shortest distance is
The points and themselves are not the closest pair; their separation is . The formula extracts only the part of that separation perpendicular to the lines.
How to identify the needed vectors
If a line is given in vector form , the point is and the direction vector is . In parametric equations such as , , , the direction vector is and a point is .
If a line is specified by two points, subtract the coordinates of those points to obtain its direction vector. For two lines, check that their direction vectors are parallel—for example, that their cross product is the zero vector—before using the parallel-lines formula.
Common mistakes
- Forgetting to divide by . The magnitude is an area, not a distance. Division by the direction-vector length converts it to a height.
- Using the distance between arbitrary points. is generally longer than the shortest distance because it can include a component along the lines.
- Using nonparallel direction vectors. The formula above assumes the lines are parallel. For skew, nonparallel lines with direction vectors and , the distance is instead .
- Treating coincident lines as separate. If the lines lie on top of each other, the cross product in the parallel-lines formula is zero, correctly giving distance zero.
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.