Distance Between Lines

In three-dimensional space, two lines can relate to each other in three distinct ways: they can intersect at a point, be parallel (never meeting but lying in the same plane), or be skew (never meeting and not lying in any common plane). For intersecting lines the distance between them is zero, but for parallel and skew lines we must develop a precise method to measure the shortest distance separating them. The distance between two lines is defined as the length of the shortest line segment that connects a point on one line to a point on the other. This shortest segment is always perpendicular to both lines simultaneously. For parallel lines, any common perpendicular has the same length, making the concept straightforward. For skew lines — the truly three-dimensional case — finding this common perpendicular requires vector algebra tools including the cross product. Mastering this concept builds the foundation for many real-world applications: engineers compute clearances between cables or pipes that run in different directions; computer graphics engines detect near-collisions between edges; and physicists model charged particle trajectories. The formulas derived here are elegant because they compress a geometric problem into a compact algebraic expression using dot and cross products.

Key takeaways
  • Set Up Vector Equations for the Two Lines
  • Find the Common Perpendicular Direction Using the Cross Product
  • Project the Connecting Vector onto the Normal
  • Special Case: Parallel Lines
  • Check Whether Lines Actually Intersect

Set Up Vector Equations for the Two Lines

Write each line in parametric vector form. Line 1 passes through point A with direction vector d₁: r₁ = a + s·d₁. Line 2 passes through point B with direction vector d₂: r₂ = b + t·d₂, where s and t are real parameters. The vector connecting the two base points is w = a − b.

Find the Common Perpendicular Direction Using the Cross Product

The vector n = d₁ × d₂ is perpendicular to both direction vectors simultaneously. If n ≠ 0 the lines are skew (or parallel if they also don't intersect). The unit normal is n̂ = n / |n|. This direction points along the unique common perpendicular connecting the two skew lines.

Project the Connecting Vector onto the Normal

The distance is the scalar projection of w = a − b onto the unit normal n̂. This projection filters out all components of w that run along either line, leaving only the perpendicular gap. Therefore: d = |w · n̂| = |(a − b) · (d₁ × d₂)| / |d₁ × d₂|. This is the scalar triple product formula.

Special Case: Parallel Lines

When the lines are parallel, d₁ × d₂ = 0 and the skew formula breaks down. Instead, project w = a − b onto the direction perpendicular to d₁ within the plane they determine. The formula becomes d = |w × d₁| / |d₁|. Geometrically this is the length of the component of w that is orthogonal to the common direction.

Check Whether Lines Actually Intersect

Before computing a non-zero distance, verify skewness. If d₁ × d₂ ≠ 0, check whether (a − b) · (d₁ × d₂) = 0. If this scalar triple product equals zero the lines are coplanar and either intersect or are parallel (test parallelism by checking if d₁ × d₂ = 0). Only if the scalar triple product is non-zero are the lines truly skew with a positive distance.

The Key Equation

d=∣(a−b)⋅(d1×d2)∣∣d1×d2∣d = \frac{|(\mathbf{a} - \mathbf{b}) \cdot (\mathbf{d}_1 \times \mathbf{d}_2)|}{|\mathbf{d}_1 \times \mathbf{d}_2|}
  • \mathbf{a} — Position vector of point on Line 1 (length units): Any fixed point lying on the first line, expressed as a position vector from the origin.
  • \mathbf{b} — Position vector of point on Line 2 (length units): Any fixed point lying on the second line, expressed as a position vector from the origin.
  • \mathbf{d}_1 — Direction vector of Line 1 (dimensionless): A non-zero vector pointing along the first line; does not need to be a unit vector.
  • \mathbf{d}_2 — Direction vector of Line 2 (dimensionless): A non-zero vector pointing along the second line; does not need to be a unit vector.
  • \mathbf{d}_1 \times \mathbf{d}_2 — Cross product (common perpendicular vector) (dimensionless): Points in the direction simultaneously perpendicular to both lines; its magnitude equals the sine of the angle between the directions.
  • d — Shortest distance (same as position vectors): The length of the unique common perpendicular segment joining the two skew lines.

Worked Example

Problem. Find the shortest distance between the two skew lines: Line 1: r₁ = (1, 2, 0) + s(1, −1, 1) and Line 2: r₂ = (2, 1, −1) + t(2, 1, −1).

d=2d = \sqrt{2}

Answer. The shortest distance between the two skew lines is √2 units.

Figure
Diagram
Distance Between Skew LinesL₁A(1,2,0)L₂B(2,1,−1)d = √2d₁=(1,−1,1)d₂=(2,1,−1)Common ⊥n = d₁×d₂ = (0, 3, 3)|n| = 3√2, d = 6/(3√2) = √2
Origins · 1 minJulius Plücker and how this was discovered
JP
Julius Plücker
1801–1868 · German

Plücker pioneered the use of coordinates for lines in three-dimensional space, developing what are now called Plücker coordinates. This system encodes a line in 3D using six numbers (four independent), enabling algebraic treatment of line geometry including distances, intersections, and skewness conditions. His work in line geometry (Liniengeometrie) created the theoretical framework within which modern formulas for distances between lines are understood. Plücker was also an experimental physicist who discovered cathode rays — the streams of electrons that later led to the invention of television tubes — making him a pioneer in both pure geometry and physics.

  • Cross Product of Vectors — The cross product d₁ × d₂ is the central calculation in finding the distance between skew lines, producing the common perpendicular direction.
  • Dot Product and Scalar Projection — The dot product projects the connecting vector onto the common perpendicular, yielding the actual distance value in the numerator of the formula.
  • Parametric Equations of Lines in Space — Lines must be expressed in vector-parametric form r = a + t·d before the distance formula can be applied.
  • Distance from a Point to a Plane — The distance between parallel lines can be reduced to this concept, and both use the same idea of scalar projection onto a normal direction.
  • Scalar Triple Product — The numerator of the skew-line distance formula is a scalar triple product, and its value being zero is the test for whether lines are coplanar.