Tutorials › Calculus III › Distances Between Parallel and Skew Lines

Cross Products, Lines, and Planes · Tutorial 97 of 999

Distances Between Parallel and Skew Lines

Use a point-to-line calculation for parallel lines and a common perpendicular to find the distance between skew lines.

Beginner 10 min read

What You'll Learn

  • Recognize parallel lines and skew lines from their direction vectors and positions.
  • Calculate the distance between parallel lines using a cross product.
  • Derive the cross-product formula for the distance between skew lines.
  • Find closest points on skew lines by requiring their connecting vector to be perpendicular to both directions.
  • Check distance calculations using points, perpendicularity, and the length of the connecting vector.

Why Distances Between Lines Need Care

Two lines in space can be parallel, intersecting, or skew. Parallel lines have the same direction, while skew lines are nonparallel and do not intersect. For either pair, the distance means the length of the shortest segment joining a point on one line to a point on the other.

For parallel lines, this shortest segment can be found by measuring from a point on one line to the other line. For skew lines, the shortest segment must be perpendicular to both lines. Cross products provide formulas for both distances and a direct way to identify the direction of that common perpendicular.

Definition: The distance between two lines is the minimum length of a segment joining a point on the first line to a point on the second. A segment that realizes this minimum is a common perpendicular when it is perpendicular to both lines.

The Two Distance Formulas

Write the lines using position vectors \(\mathbf{p}\) and \(\mathbf{q}\), and nonzero direction vectors \(\mathbf{u}\) and \(\mathbf{v}\):

$$ L_1:\ \mathbf{x}=\mathbf{p}+s\mathbf{u}, \qquad L_2:\ \mathbf{x}=\mathbf{q}+t\mathbf{v}. $$

Here \(s\) and \(t\) range over all real numbers. For parallel lines, the direction vectors are scalar multiples of one another. For skew lines, they are not scalar multiples, and the lines do not intersect. Set \(\mathbf{r}=\mathbf{q}-\mathbf{p}\), the vector from the chosen point on the first line to the chosen point on the second.

Theorem: If the lines are parallel, their distance is the distance from \(\mathbf{q}\) to \(L_1\): $$ d=\frac{\lVert\mathbf{r}\times\mathbf{u}\rVert}{\lVert\mathbf{u}\rVert}. $$ If the lines are skew, their distance is $$ d=\frac{\left|\mathbf{r}\cdot(\mathbf{u}\times\mathbf{v})\right|} {\lVert\mathbf{u}\times\mathbf{v}\rVert}. $$ The skew-lines formula requires \(\mathbf{u}\times\mathbf{v}\ne\mathbf{0}\), which holds when the directions are not parallel.

The parallel formula is the point-to-line distance formula applied to the point \(\mathbf{q}\). The skew-lines formula uses a vector perpendicular to both directions: \(\mathbf{u}\times\mathbf{v}\). The absolute value ensures the distance is nonnegative.

Distance Between Parallel Lines

When the lines are parallel, moving along either line does not change the perpendicular separation between them. Therefore, choose any point on one line and find its distance to the other line. For example, with \(\mathbf{q}\) on \(L_2\), the cross product \(\mathbf{r}\times\mathbf{u}\) measures the area of a parallelogram with base length \(\lVert\mathbf{u}\rVert\). Dividing that area by the base length gives the perpendicular height, which is the distance.

Worked Example: Distance Between Parallel Lines

Find the distance between

$$ L_1:\ \mathbf{x}=(1,0,2)+s(2,-1,2), \qquad L_2:\ \mathbf{x}=(0,3,1)+t(4,-2,4). $$

The direction vectors are \(\mathbf{u}=(2,-1,2)\) and \(\mathbf{v}=(4,-2,4)=2\mathbf{u}\), so the lines are parallel. Take \(\mathbf{p}=(1,0,2)\) and \(\mathbf{q}=(0,3,1)\). Then

$$ \mathbf{r}=\mathbf{q}-\mathbf{p}=(-1,3,-1). $$

Compute the cross product and direction length:

$$ \mathbf{r}\times\mathbf{u} = \begin{vmatrix} \mathbf{i}&\mathbf{j}&\mathbf{k}\\ -1&3&-1\\ 2&-1&2 \end{vmatrix} =(5,0,-5), \qquad \lVert\mathbf{r}\times\mathbf{u}\rVert=5\sqrt{2}, \qquad \lVert\mathbf{u}\rVert=3. $$

Thus

$$ d=\frac{5\sqrt{2}}{3}. $$

To check, the point \(\mathbf{q}\) lies on \(L_2\). Its projection parameter onto \(L_1\) is \(\mathbf{r}\cdot\mathbf{u}/(\mathbf{u}\cdot\mathbf{u})=-7/9\). The point on \(L_1\) directly across from \(\mathbf{q}\) is therefore \(\mathbf{p}-\frac79\mathbf{u}\), and the connecting vector is

$$ \mathbf{q}-\left(\mathbf{p}-\frac79\mathbf{u}\right) =\mathbf{r}+\frac79\mathbf{u} =\left(\frac59,\frac{20}{9},\frac59\right). $$

Its dot product with \(\mathbf{u}\) is \(\frac{10}{9}-\frac{20}{9}+\frac{10}{9}=0\), so it is perpendicular to the lines. Its length is \(\sqrt{450/81}=5\sqrt{2}/3\), agreeing with the formula.

Why the Skew-Lines Formula Works

For skew lines, the vector \(\mathbf{n}=\mathbf{u}\times\mathbf{v}\) is nonzero and perpendicular to both directions. The scalar triple product \(\mathbf{r}\cdot\mathbf{n}\) measures the signed component of \(\mathbf{r}\) in the direction normal to both lines. Dividing its absolute value by \(\lVert\mathbf{n}\rVert\) gives the length of that component. The following argument shows why this component is exactly the minimum separation.

Derivation: A vector joining a point on \(L_1\) to a point on \(L_2\) has the form $$ \mathbf{D}(s,t)=\mathbf{r}+t\mathbf{v}-s\mathbf{u}. $$ At the closest points, this vector must be perpendicular to both line directions. The conditions are $$ \mathbf{D}\cdot\mathbf{u}=0, \qquad \mathbf{D}\cdot\mathbf{v}=0. $$ These are two linear equations for \(s\) and \(t\). Their coefficient matrix is the Gram matrix of \(\mathbf{u},\mathbf{v}\), whose determinant is $$ (\mathbf{u}\cdot\mathbf{u})(\mathbf{v}\cdot\mathbf{v})-(\mathbf{u}\cdot\mathbf{v})^2 =\lVert\mathbf{u}\times\mathbf{v}\rVert^2>0. $$ Thus the equations have a unique solution for skew lines. Call the resulting connecting vector \(\mathbf{D}_0\). Any other connecting vector differs from it by a vector \(\mathbf{w}\) in the span of \(\mathbf{u}\) and \(\mathbf{v}\). Since \(\mathbf{D}_0\) is perpendicular to both directions, it is perpendicular to \(\mathbf{w}\). Therefore $$ \lVert\mathbf{D}_0+\mathbf{w}\rVert^2 =\lVert\mathbf{D}_0\rVert^2+\lVert\mathbf{w}\rVert^2 \ge \lVert\mathbf{D}_0\rVert^2. $$ So \(\mathbf{D}_0\) gives the minimum distance. Also, \(\mathbf{D}_0\) is parallel to \(\mathbf{n}\), and \(\mathbf{D}_0\cdot\mathbf{n}=\mathbf{r}\cdot\mathbf{n}\), because \(\mathbf{u}\cdot\mathbf{n}=\mathbf{v}\cdot\mathbf{n}=0\). Hence $$ \lVert\mathbf{D}_0\rVert =\frac{|\mathbf{D}_0\cdot\mathbf{n}|}{\lVert\mathbf{n}\rVert} =\frac{|\mathbf{r}\cdot(\mathbf{u}\times\mathbf{v})|} {\lVert\mathbf{u}\times\mathbf{v}\rVert}. $$

Finding the Common Perpendicular Directly

The formula gives the distance without finding the closest points. When the points themselves are needed, solve the two perpendicularity equations. The check is essential: the resulting points must lie on their respective lines, and the vector joining them must have zero dot product with both directions.

Worked Example: Closest Points on Two Skew Lines

Find the distance between

$$ L_1:\ \mathbf{x}=s(1,1,0), \qquad L_2:\ \mathbf{x}=(1,0,0)+t(0,1,1). $$

Here \(\mathbf{p}=(0,0,0)\), \(\mathbf{q}=(1,0,0)\), \(\mathbf{u}=(1,1,0)\), \(\mathbf{v}=(0,1,1)\), and \(\mathbf{r}=(1,0,0)\). The cross product and triple product are

$$ \mathbf{u}\times\mathbf{v}=(1,-1,1), \qquad \lVert\mathbf{u}\times\mathbf{v}\rVert=\sqrt{3}, \qquad \mathbf{r}\cdot(\mathbf{u}\times\mathbf{v})=1. $$

The directions are nonparallel, and the nonzero triple product shows that the lines are not coplanar, so they are skew. The distance formula gives \(d=1/\sqrt{3}\).

For the closest points, the connecting vector from a point on \(L_1\) to a point on \(L_2\) is

$$ \mathbf{D}(s,t)=(1,0,0)+t(0,1,1)-s(1,1,0) =(1-s,t-s,t). $$

Impose perpendicularity to each direction:

$$ \mathbf{D}\cdot\mathbf{u}=1+t-2s=0, \qquad \mathbf{D}\cdot\mathbf{v}=2t-s=0. $$

The second equation gives \(s=2t\). Substituting into the first gives \(1+t-4t=0\), so \(t=1/3\) and \(s=2/3\). The closest points are

$$ \mathbf{x}_1=\frac23(1,1,0)=\left(\frac23,\frac23,0\right), \qquad \mathbf{x}_2=(1,0,0)+\frac13(0,1,1) =\left(1,\frac13,\frac13\right). $$

Their difference is \(\mathbf{x}_2-\mathbf{x}_1=(1/3,-1/3,1/3)\). Its dot products with \(\mathbf{u}\) and \(\mathbf{v}\) are \(1/3-1/3=0\) and \(-1/3+1/3=0\), respectively. Its length is \(\sqrt{3/9}=1/\sqrt{3}\), confirming the formula and the perpendicularity conditions.

A Second Skew-Lines Calculation

Worked Example: Distance and Common Perpendicular

Consider

$$ L_1:\ \mathbf{x}=(1,-1,0)+s(1,0,1), \qquad L_2:\ \mathbf{x}=(0,2,3)+t(0,2,0). $$

Take \(\mathbf{p}=(1,-1,0)\), \(\mathbf{q}=(0,2,3)\), \(\mathbf{u}=(1,0,1)\), and \(\mathbf{v}=(0,2,0)\). Then \(\mathbf{r}=(-1,3,3)\), and

$$ \mathbf{u}\times\mathbf{v}=(-2,0,2), \qquad \lVert\mathbf{u}\times\mathbf{v}\rVert=2\sqrt{2}, \qquad \mathbf{r}\cdot(\mathbf{u}\times\mathbf{v})=2+6=8. $$

Thus the distance is \(8/(2\sqrt{2})=2\sqrt{2}\). To find the closest points, use \(\mathbf{D}=\mathbf{r}+t\mathbf{v}-s\mathbf{u}\). The perpendicularity equations are

$$ \mathbf{D}\cdot\mathbf{u}=2-2s=0, \qquad \mathbf{D}\cdot\mathbf{v}=6+4t=0. $$

They give \(s=1\) and \(t=-3/2\). The connecting vector is

$$ \mathbf{D}=(-1,3,3)+(0,-3,0)-(1,0,1)=(-2,0,2). $$

Its dot products with \(\mathbf{u}\) and \(\mathbf{v}\) are \(-2+2=0\) and \(0\), so it is perpendicular to both lines. Its length is \(\sqrt{4+4}=2\sqrt{2}\), as required.

Distinguishing Skew Lines from Other Pairs

Do not apply the skew-lines formula without first checking the geometric situation. If the directions are parallel, the cross product in its denominator is zero, so use the parallel-lines formula instead. If the directions are not parallel, the triple product helps distinguish skew lines from intersecting ones: a zero triple product means \(\mathbf{r}\) lies in the plane spanned by the two directions. The lines are then coplanar and, because their directions are nonparallel, they intersect. Their distance is zero.

Practical check: For nonparallel lines, a nonzero value of \(\mathbf{r}\cdot(\mathbf{u}\times\mathbf{v})\) identifies skew lines. A zero value identifies coplanar lines; in this nonparallel case, they intersect. Coincident lines are a parallel case with distance zero.

A Common Mistake

A frequent error is to use the point-to-line formula with a point on one skew line and the direction of the other line, then assume this gives the distance between the two lines. It generally does not: the selected point may not be the endpoint of the shortest connecting segment.

Worked Example: Why a Point-to-Line Calculation Can Fail

For the skew lines from the earlier example, take \(\mathbf{q}=(1,0,0)\) on \(L_2\), \(\mathbf{p}=(0,0,0)\) on \(L_1\), and \(\mathbf{u}=(1,1,0)\). The point-to-line calculation gives

$$ \frac{\lVert(\mathbf{q}-\mathbf{p})\times\mathbf{u}\rVert} {\lVert\mathbf{u}\rVert} = \frac{\lVert(1,0,0)\times(1,1,0)\rVert}{\sqrt{2}} =\frac{1}{\sqrt{2}}. $$

This is the distance from \(\mathbf{q}\) to \(L_1\), not the distance between the two lines. The actual line-to-line distance is \(1/\sqrt{3}\), as the skew-lines formula and common perpendicular show. The correction is to use the skew-lines formula or find the points where the connecting segment is perpendicular to both directions.

Choosing and Checking a Method

Start by writing each line with a point and a nonzero direction vector. Then classify the pair before calculating. The distance formulas depend on the geometry: parallel lines use one line's direction and a point on the other, while skew lines use both directions and their common normal.

1
Compare directions.
If \(\mathbf{u}\times\mathbf{v}=\mathbf{0}\), the directions are parallel; otherwise they are not.
2
Classify the lines.
For nonparallel directions, check whether \(\mathbf{r}\cdot(\mathbf{u}\times\mathbf{v})\) is zero. Zero means the lines intersect; nonzero means they are skew.
3
Use the appropriate formula.
For parallel lines use \(\lVert\mathbf{r}\times\mathbf{u}\rVert/\lVert\mathbf{u}\rVert\). For skew lines use \(\left|\mathbf{r}\cdot(\mathbf{u}\times\mathbf{v})\right|/\lVert\mathbf{u}\times\mathbf{v}\rVert\).
4
Verify when needed.
If you find closest points, confirm they lie on their lines, their connecting vector has the calculated length, and its dot products with both direction vectors are zero.

These methods matter because they turn a spatial picture into a small set of vector calculations. The perpendicularity check also explains the geometry of the answer: the distance is not just the length of an arbitrary connector, but the length of the shortest one.

Check Your Understanding

Use the line directions and points carefully in each question.

  1. What condition on two direction vectors identifies parallel lines?
  2. Why does the distance between parallel lines equal the distance from any point on one line to the other line?
  3. For skew lines, why is \(\mathbf{u}\times\mathbf{v}\) the direction of the common perpendicular?
  4. What does a zero scalar triple product imply when the line directions are nonparallel?
  5. For the lines \(\mathbf{x}=s(1,1,0)\) and \(\mathbf{x}=(1,0,0)+t(0,1,1)\), find the parameters of the closest points and verify the connecting vector is perpendicular to both directions.