Shortest Distance Between Two Skew Lines in 3D

April 15, 2026

Problem

Explain this

Explanation

We have two lines in 3D space given in vector form:

r1=a1+λb1,r2=a2+μb2\vec r_1 = \vec a_1 + \lambda \vec b_1, \qquad \vec r_2 = \vec a_2 + \mu \vec b_2
  • a1,a2\vec a_1, \vec a_2 are fixed position vectors (points on each line).
  • b1,b2\vec b_1, \vec b_2 are direction vectors of the lines.
  • λ,μ\lambda, \mu are real parameters.

We want the shortest distance between these two lines when they are skew (not parallel, and they do not intersect).


Geometric Idea

In 3D, two lines can be:

  1. Intersecting – they cross at some point.
  2. Parallel – same direction, possibly different positions.
  3. Skew – not parallel and do not intersect; they are “offset” in 3D.

For skew lines, the shortest segment connecting them:

  • Is perpendicular to both lines.
  • Lies along the direction of the cross product of their direction vectors.

Let

n=b1×b2\vec n = \vec b_1 \times \vec b_2

Then n\vec n is perpendicular to both b1\vec b_1 and b2\vec b_2. The shortest segment between the lines must be parallel to n\vec n.

We also have the vector between two reference points (one on each line):

d=a2a1\vec d = \vec a_2 - \vec a_1

This d\vec d connects a point on line 1 to a point on line 2.

The component of d\vec d along n\vec n gives the shortest distance between the lines, because that’s the part of d\vec d that is perpendicular to both lines.


Deriving the Formula

  1. Compute the normal vector to both lines:
n=b1×b2\vec n = \vec b_1 \times \vec b_2
  • If n=0\vec n = \vec 0 then b1\vec b_1 and b2\vec b_2 are parallel, and the formula below does not apply (handle the parallel case separately).
  1. The signed scalar projection of d=a2a1\vec d = \vec a_2 - \vec a_1 on n\vec n is:
proj length=dnn\text{proj length} = \frac{\vec d \cdot \vec n}{\lVert \vec n \rVert}
  1. The shortest distance is the absolute value of this projection:
Distance=proj length=dnn\text{Distance} = \left|\text{proj length}\right| = \frac{\left|\vec d \cdot \vec n\right|}{\lVert \vec n \rVert}

Substituting d=a2a1\vec d = \vec a_2 - \vec a_1 and n=b1×b2\vec n = \vec b_1 \times \vec b_2:

Distance=(a2a1)(b1×b2)b1×b2\boxed{\text{Distance} = \dfrac{\left|\,(\vec a_2 - \vec a_1) \cdot (\vec b_1 \times \vec b_2)\,\right|}{\left\|\vec b_1 \times \vec b_2\right\|}}

This is exactly the formula in the tip.


Why Students Mix Up Parallel and Skew

  • Parallel lines in 3D share the same direction (b1\vec b_1 is a scalar multiple of b2\vec b_2), so their cross product is zero: b1×b2=0\vec b_1 \times \vec b_2 = \vec 0.
  • Skew lines have b1×b20\vec b_1 \times \vec b_2 \neq \vec 0 and do not intersect.

The formula uses b1×b2\vec b_1 \times \vec b_2 in both numerator and denominator. If the lines are parallel, the denominator becomes zero, and the formula breaks down — this is a signal that you must treat the parallel case separately (distance from a point to a line).


Visual Interpretation (What the Visualization Shows)

The visualization animates the following:

  • Two skew lines in 3D projected onto the 2D canvas.
  • A moving point on each line (controlled by parameters λ\lambda and μ\mu).
  • The shortest connecting segment between the lines, which is perpendicular to both:
    • This segment aligns with n=b1×b2\vec n = \vec b_1 \times \vec b_2.
    • Its length equals the formula:
Distance=(a2a1)(b1×b2)b1×b2\text{Distance} = \frac{|(\vec a_2 - \vec a_1) \cdot (\vec b_1 \times \vec b_2)|}{\lVert \vec b_1 \times \vec b_2 \rVert}

By adjusting direction vectors and positions, you can see:

  • When b1\vec b_1 and b2\vec b_2 get closer to parallel, the cross product shrinks and the geometry degenerates.
  • How the shortest segment "slides" along the lines but always stays perpendicular to both.

Step‑by‑Step Use of the Formula

  1. Identify a1,a2,b1,b2\vec a_1, \vec a_2, \vec b_1, \vec b_2 from the line equations.
  2. Compute:
    • d=a2a1\vec d = \vec a_2 - \vec a_1
    • n=b1×b2\vec n = \vec b_1 \times \vec b_2
  3. Check n0\vec n \neq \vec 0 (if zero, lines are parallel).
  4. Compute the dot product dn\vec d \cdot \vec n.
  5. Compute n\lVert \vec n \rVert.
  6. Plug into:
Distance=dnn\text{Distance} = \frac{|\vec d \cdot \vec n|}{\lVert \vec n \rVert}

This is the minimal distance between the two skew lines.

Interactive Visualization

Parameters

-2.00
-1.00
0.00
1.00
1.50
0.50
1.50
2.00
1.00
-1.20
1.00
1.80
0.00
0.00
0.80
80.00
Your turn

Got your own math or physics problem?

Turn any problem into an interactive visualization like this one — powered by AI, generated in seconds. Free to try, no credit card required.

Sign Up Free to Try It30 free visualizations every day
Shortest Distance Between Two Skew Lines in 3D | MathSpin