Distance and shortest distance

Two roads that cross on a map might really pass at different heights on a flyover — never touching, never parallel, just quietly skew in space. Three-dimensional geometry needs a way to measure "how far apart" two such lines really are, and also how far a stray point sits from a line it doesn't lie on. This section gives both measurements: the distance of a point from a line, and the shortest distance between two lines, with the skew case as the signature result. Both answers come from the same idea — the cross product turns a distance question into an area-over-base question, so no calculus is needed, only vectors you already know from earlier in this chapter.

The core insight

The shortest distance between two lines is always measured along their common perpendicular, and the cross product converts that perpendicular length into a ratio of a triple-product "volume" to a cross-product "area."

The core idea

Three ways two lines in space can sit. Two lines either intersect, are parallel, or are skew — neither meeting nor parallel, lying in different planes (an overpass and the road beneath it). For lines r⃗=a⃗1+λb⃗1\vec r=\vec a_1+\lambda\vec b_1 and r⃗=a⃗2+μb⃗2\vec r=\vec a_2+\mu\vec b_2, the coplanarity test is

(a⃗2−a⃗1)⋅(b⃗1×b⃗2)=0,(\vec a_2-\vec a_1)\cdot(\vec b_1\times\vec b_2)=0,

where: a⃗1,a⃗2\vec a_1,\vec a_2 are position vectors of any point on each line and b⃗1,b⃗2\vec b_1,\vec b_2 are their direction vectors. If this scalar triple product is zero the lines are coplanar (they intersect or are parallel); if it is non-zero, they are skew.

Distance of a point from a line. For point PP (position vector p⃗\vec p) and line r⃗=a⃗+λb⃗\vec r=\vec a+\lambda\vec b, dropping a perpendicular from PP gives

d=∣(p⃗−a⃗)×b⃗∣∣b⃗∣.d = \frac{|(\vec p-\vec a)\times \vec b|}{|\vec b|}.

where: (p⃗−a⃗)(\vec p-\vec a) joins a known point on the line to PP, and b⃗\vec b is the line's direction. The cross product's magnitude is the area of the parallelogram spanned by these two vectors; dividing by the base ∣b⃗∣|\vec b| leaves the height — exactly the perpendicular distance.

Shortest distance for parallel lines r⃗=a⃗1+λb⃗\vec r=\vec a_1+\lambda\vec b and r⃗=a⃗2+μb⃗\vec r=\vec a_2+\mu\vec b (same direction b⃗\vec b):

d=∣b⃗×(a⃗2−a⃗1)∣b⃗∣∣.d = \left|\frac{\vec b\times(\vec a_2-\vec a_1)}{|\vec b|}\right|.

This is the point-from-line formula in disguise — any point on the second line measured against the first. For skew lines, no single perpendicular from a point works; instead there is a unique line segment perpendicular to both lines at once, and its length is the shortest distance — the subject of the derivation below. In Cartesian form, the same formulas apply once a⃗1,a⃗2,b⃗1,b⃗2\vec a_1,\vec a_2,\vec b_1,\vec b_2 are read off as the given points and direction ratios, and every cross/dot product is expanded component-wise as a 3×33\times3 determinant. It helps to notice that all three formulas — point-from-line, parallel-lines, and skew-lines — are variations on one theme: turn the gap between two geometric objects into a vector, use a cross product to build a perpendicular quantity out of the directions involved, and divide by a length to leave behind a pure distance. The skew-line case is the richest because two independent directions are in play, so the perpendicular direction b⃗1×b⃗2\vec b_1\times\vec b_2 itself has to be constructed before any projection can happen; in the point-from-line and parallel-lines cases there is only one direction, b⃗\vec b, to work with throughout.

Figure
Two skew lines in space with their unique common perpendicular segment drawn as the shortest distance between them
Skew lines and their common perpendicular line 1 line 2 common perpendicular, length d The lines never meet and are not parallel; d is the length of the one segment perpendicular to both
Derivation AShortest distance between two skew lines

The goal is to find the length of the unique line segment that is perpendicular to both skew lines r⃗=a⃗1+λb⃗1\vec r=\vec a_1+\lambda\vec b_1 and r⃗=a⃗2+μb⃗2\vec r=\vec a_2+\mu\vec b_2 simultaneously, starting only from their point-and-direction vector equations and the geometric meaning of the cross and dot products, without appealing to calculus or coordinates.

Step 1. Build a direction perpendicular to both lines at once. A vector perpendicular to b⃗1\vec b_1 and also perpendicular to b⃗2\vec b_2 is exactly n⃗=b⃗1×b⃗2\vec n=\vec b_1\times\vec b_2, by the defining property of the cross product. This n⃗\vec n points along the common perpendicular direction — the one direction that meets both lines at right angles.

Step 2. Connect the two lines with a single vector. Pick any point on each line, giving position vectors a⃗1\vec a_1 and a⃗2\vec a_2; the vector joining them is a⃗2−a⃗1\vec a_2-\vec a_1. This vector generally has some component along n⃗\vec n and some component lying in the plane containing both directions b⃗1,b⃗2\vec b_1,\vec b_2.

Step 3. Isolate the component along the common perpendicular. Only the part of a⃗2−a⃗1\vec a_2-\vec a_1 that lies along n⃗\vec n actually measures the separation between the lines, since motion along b⃗1\vec b_1 or b⃗2\vec b_2 keeps a point on its own line. The length of that projection is the scalar projection formula, ∣(a⃗2−a⃗1)⋅n⃗∣n⃗∣∣\left|(\vec a_2-\vec a_1)\cdot\dfrac{\vec n}{|\vec n|}\right|.

Step 4. Substitute n⃗=b⃗1×b⃗2\vec n=\vec b_1\times\vec b_2 back in to get the shortest distance,

d=∣(a⃗2−a⃗1)⋅(b⃗1×b⃗2)∣b⃗1×b⃗2∣∣.d=\left|\frac{(\vec a_2-\vec a_1)\cdot(\vec b_1\times\vec b_2)}{|\vec b_1\times\vec b_2|}\right|.

The numerator is the scalar triple product [a⃗2−a⃗1, b⃗1, b⃗2][\vec a_2-\vec a_1,\ \vec b_1,\ \vec b_2], geometrically the volume of the parallelepiped built from these three vectors; the denominator ∣b⃗1×b⃗2∣|\vec b_1\times\vec b_2| is the area of its base. Volume over base area is height — and that height is precisely the perpendicular distance between the two skew lines. If b⃗1×b⃗2=0⃗\vec b_1\times\vec b_2=\vec 0 the lines are parallel instead and this formula does not apply; use the parallel-line formula there.

Worked example

Find the shortest distance between the skew lines r⃗=(i^+j^)+λ(2i^−j^+k^)\vec r = (\hat i+\hat j) + \lambda(2\hat i-\hat j+\hat k) and r⃗=(2i^+j^−k^)+μ(3i^−5j^+2k^)\vec r = (2\hat i+\hat j-\hat k)+\mu(3\hat i-5\hat j+2\hat k).

Step 1. Read off the vectors: a⃗1=i^+j^\vec a_1=\hat i+\hat j, b⃗1=2i^−j^+k^\vec b_1=2\hat i-\hat j+\hat k, a⃗2=2i^+j^−k^\vec a_2=2\hat i+\hat j-\hat k, b⃗2=3i^−5j^+2k^\vec b_2=3\hat i-5\hat j+2\hat k, so a⃗2−a⃗1=i^−k^\vec a_2-\vec a_1=\hat i-\hat k.

Step 2. Compute b⃗1×b⃗2\vec b_1\times\vec b_2 by the determinant

∣i^j^k^2−113−52∣=i^[(−1)(2)−(1)(−5)]−j^[(2)(2)−(1)(3)]+k^[(2)(−5)−(−1)(3)]=3i^−j^−7k^.\begin{vmatrix}\hat i&\hat j&\hat k\\2&-1&1\\3&-5&2\end{vmatrix} = \hat i[(-1)(2)-(1)(-5)] -\hat j[(2)(2)-(1)(3)] +\hat k[(2)(-5)-(-1)(3)] = 3\hat i-\hat j-7\hat k.

Step 3. Dot this with a⃗2−a⃗1\vec a_2-\vec a_1: (i^−k^)⋅(3i^−j^−7k^)=3+0+7=10(\hat i-\hat k)\cdot(3\hat i-\hat j-7\hat k) = 3+0+7=10. Since this is non-zero, the lines are confirmed skew.

Step 4. Find the magnitude ∣b⃗1×b⃗2∣=∣3i^−j^−7k^∣=9+1+49=59|\vec b_1\times\vec b_2|=|3\hat i-\hat j-7\hat k|=\sqrt{9+1+49}=\sqrt{59}, and divide: d=∣1059∣=1059d=\left|\dfrac{10}{\sqrt{59}}\right|=\dfrac{10}{\sqrt{59}} units.

The shortest distance between the two skew lines is d=1059d=\dfrac{10}{\sqrt{59}} units.

Competitive stretch

The same setup gives the point-from-line formula near-for-free: for P(1,0,−3)P(1,0,-3) and the line x+12=y−33=z−1\dfrac{x+1}{2}=\dfrac{y-3}{3}=\dfrac{z}{-1} (through A(−1,3,0)A(-1,3,0), direction b⃗=2i^+3j^−k^\vec b=2\hat i+3\hat j-\hat k), (p⃗−a⃗)×b⃗=12i^−4j^+12k^(\vec p-\vec a)\times\vec b=12\hat i-4\hat j+12\hat k, of magnitude 304=419\sqrt{304}=4\sqrt{19}, and ∣b⃗∣=14|\vec b|=\sqrt{14}, giving d=41914≈4.66d=\dfrac{4\sqrt{19}}{\sqrt{14}}\approx 4.66 units — the identical cross-product-over-magnitude pattern, just with one line and one external point instead of two lines.

Common traps

  • Using the parallel-lines formula (a plain cross product with a single b⃗\vec b) on lines that are actually skew, or the skew formula on lines that are parallel — check whether b⃗1\vec b_1 and b⃗2\vec b_2 are proportional before choosing.
  • Sign or cofactor-order slips inside the 3×33\times3 determinant when expanding b⃗1×b⃗2\vec b_1\times\vec b_2 or (p⃗−a⃗)×b⃗(\vec p-\vec a)\times\vec b; one misplaced sign changes the final distance.
  • Dropping the absolute value at the end — a distance cannot be negative, even though the scalar triple product inside can come out negative.
  • Declaring lines "intersecting" from a rough sketch instead of formally testing (a⃗2−a⃗1)⋅(b⃗1×b⃗2)=0(\vec a_2-\vec a_1)\cdot(\vec b_1\times\vec b_2)=0.

Ask the tutor: if setting up the determinant for b⃗1×b⃗2\vec b_1\times\vec b_2 feels error-prone, ask the AI tutor to walk through the cofactor expansion one row at a time with your own numbers.

How do I know whether to use the skew-line formula or the parallel-line formula?

Compare the direction vectors first. If b⃗1\vec b_1 and b⃗2\vec b_2 are scalar multiples of each other, the lines are parallel, and you use d=∣b⃗×(a⃗2−a⃗1)∣/∣b⃗∣d=\left|\vec b\times(\vec a_2-\vec a_1)\right|/|\vec b| with either direction vector. If they are not proportional, compute b⃗1×b⃗2\vec b_1\times\vec b_2; if it is non-zero the lines are skew and you use the full triple-product formula. Checking proportionality takes seconds and avoids applying the wrong formula entirely.

Why does a non-zero scalar triple product mean the lines are skew rather than just non-parallel?

The scalar triple product (a⃗2−a⃗1)⋅(b⃗1×b⃗2)(\vec a_2-\vec a_1)\cdot(\vec b_1\times\vec b_2) is the volume of the parallelepiped formed by the connecting vector and the two directions. If this volume is exactly zero, all three vectors are coplanar, meaning the connecting vector, and hence both lines, lie in one plane — so the lines either meet or run parallel within that plane. A non-zero volume means the three vectors cannot fit in a single plane, so the lines cannot be coplanar; having ruled out both parallel and intersecting, only skew remains.

Is the distance of a point from a line just a special case of the skew-line formula?

Yes, in spirit. Treat the point PP as lying on an imaginary second "line" with zero length (any direction works since it never moves), and the connecting vector becomes p⃗−a⃗\vec p-\vec a. The role of b⃗1×b⃗2\vec b_1\times\vec b_2 collapses to just b⃗\vec b, the one line's direction, and the formula d=∣(p⃗−a⃗)×b⃗∣/∣b⃗∣d=|(\vec p-\vec a)\times\vec b|/|\vec b| is exactly the same area-over-base logic: the cross product gives a parallelogram area, dividing by the base length gives the height, which is the perpendicular distance.

Before this

Where this leads