Shortest Distance Between Two Lines

Skew, parallel and intersecting lines

In two dimensions, two lines either meet or are parallel. In three dimensions there is a third case: skew lines, which are not parallel and never meet because they don't lie in a common plane. Which formula you use depends on which case you have.

Which formula to use
LinesHow to tellShortest distance
IntersectingNot parallel, and (a2⃗−a1⃗)⋅(b1⃗×b2⃗)=0(\vec{a_2}-\vec{a_1})\cdot(\vec{b_1}\times\vec{b_2}) = 00
SkewNot parallel, and that product is not 0∣(a2⃗−a1⃗)⋅(b1⃗×b2⃗)∣∣b1⃗×b2⃗∣\dfrac{\left|(\vec{a_2}-\vec{a_1})\cdot(\vec{b_1}\times\vec{b_2})\right|}{|\vec{b_1}\times\vec{b_2}|}
Parallelb1⃗\vec{b_1} and b2⃗\vec{b_2} are multiples of each other∣b⃗×(a2⃗−a1⃗)∣∣b⃗∣\dfrac{\left|\vec{b}\times(\vec{a_2}-\vec{a_1})\right|}{|\vec{b}|}

The formula

For two lines r⃗=a1⃗+λb1⃗\vec{r}=\vec{a_1}+\lambda\vec{b_1} and r⃗=a2⃗+μb2⃗\vec{r}=\vec{a_2}+\mu\vec{b_2} that don't intersect, the shortest distance between them is:

d=∣(a2⃗−a1⃗)⋅(b1⃗×b2⃗)∣∣b1⃗×b2⃗∣d = \dfrac{\left|(\vec{a_2}-\vec{a_1})\cdot(\vec{b_1}\times\vec{b_2})\right|}{|\vec{b_1}\times\vec{b_2}|}

Why it works: b1⃗×b2⃗\vec{b_1}\times\vec{b_2} is perpendicular to both lines, so the shortest connecting segment runs along it. Dividing by its length gives a unit vector in that direction, and the dot product projects the gap between the two starting points a2⃗−a1⃗\vec{a_2}-\vec{a_1} onto it.

Worked example

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

Solution: Here a2⃗−a1⃗=−i^+3j^−3k^\vec{a_2}-\vec{a_1} = -\hat{i}+3\hat{j}-3\hat{k}, b1⃗=(1,2,−1)\vec{b_1}=(1,2,-1), b2⃗=(2,−1,1)\vec{b_2}=(2,-1,1).

b1⃗×b2⃗=(1,−3,−5),∣b1⃗×b2⃗∣=1+9+25=35\vec{b_1}\times\vec{b_2} = (1,-3,-5), \qquad |\vec{b_1}\times\vec{b_2}| = \sqrt{1+9+25}=\sqrt{35}(a2⃗−a1⃗)⋅(b1⃗×b2⃗)=(−1)(1)+(3)(−3)+(−3)(−5)=5(\vec{a_2}-\vec{a_1})\cdot(\vec{b_1}\times\vec{b_2}) = (-1)(1)+(3)(-3)+(-3)(-5) = 5d=535=357≈0.845d = \dfrac{5}{\sqrt{35}} = \dfrac{\sqrt{35}}{7} \approx 0.845

A second worked example

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

Solution: a2⃗−a1⃗=−3i^+j^+3k^\vec{a_2}-\vec{a_1} = -3\hat{i}+\hat{j}+3\hat{k}, b1⃗=(1,1,2)\vec{b_1}=(1,1,2), b2⃗=(3,0,1)\vec{b_2}=(3,0,1).

b1⃗×b2⃗=(1,5,−3),∣b1⃗×b2⃗∣=1+25+9=35\vec{b_1}\times\vec{b_2} = (1,5,-3), \qquad |\vec{b_1}\times\vec{b_2}| = \sqrt{1+25+9}=\sqrt{35}(a2⃗−a1⃗)⋅(b1⃗×b2⃗)=(−3)(1)+(1)(5)+(3)(−3)=−7(\vec{a_2}-\vec{a_1})\cdot(\vec{b_1}\times\vec{b_2}) = (-3)(1)+(1)(5)+(3)(-3) = -7d=735=355≈1.183d = \dfrac{7}{\sqrt{35}} = \dfrac{\sqrt{35}}{5} \approx 1.183

The dot product came out negative, which only means the cross product points the other way. The absolute value in the formula takes care of it.

Worked example: parallel lines

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

Solution: Both lines have direction b⃗=(1,2,2)\vec{b} = (1,2,2), so they are parallel and b1⃗×b2⃗=0⃗\vec{b_1}\times\vec{b_2} = \vec{0}: the skew-line formula would divide by zero. Use the parallel-line formula with a2⃗−a1⃗=(2,1,−3)\vec{a_2}-\vec{a_1} = (2,1,-3):

b⃗×(a2⃗−a1⃗)=∣i^j^k^12221−3∣=−8i^+7j^−3k^\vec{b}\times(\vec{a_2}-\vec{a_1}) = \begin{vmatrix} \hat{i} & \hat{j} & \hat{k} \\ 1 & 2 & 2 \\ 2 & 1 & -3 \end{vmatrix} = -8\hat{i}+7\hat{j}-3\hat{k}d=64+49+91+4+4=1223≈3.68d = \dfrac{\sqrt{64+49+9}}{\sqrt{1+4+4}} = \dfrac{\sqrt{122}}{3} \approx 3.68

Lines given in Cartesian form

For x−x1a1=y−y1b1=z−z1c1\dfrac{x-x_1}{a_1}=\dfrac{y-y_1}{b_1}=\dfrac{z-z_1}{c_1} and x−x2a2=y−y2b2=z−z2c2\dfrac{x-x_2}{a_2}=\dfrac{y-y_2}{b_2}=\dfrac{z-z_2}{c_2}, read off a1⃗=(x1,y1,z1)\vec{a_1} = (x_1, y_1, z_1) and b1⃗=(a1,b1,c1)\vec{b_1} = (a_1, b_1, c_1), and the same for the second line. The numerator of the skew-line formula is then a single determinant:

∣x2−x1y2−y1z2−z1a1b1c1a2b2c2∣\begin{vmatrix} x_2-x_1 & y_2-y_1 & z_2-z_1 \\ a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \end{vmatrix}

If that determinant is 0 and the lines aren't parallel, they intersect.

Common mistakes

  • Using the skew formula on parallel lines. If b1⃗×b2⃗=0⃗\vec{b_1}\times\vec{b_2} = \vec{0}, switch to the parallel-line formula instead of reporting an undefined answer.
  • Reading the point and direction the wrong way round. In x+12\dfrac{x+1}{2}, the point has x1=−1x_1 = -1 (the sign flips) and the direction ratio is 2.
  • Dropping the absolute value. A distance can't be negative. A negative dot product just means the cross product happened to point the other way.
  • Forgetting to check for intersection. A numerator of 0 means the lines meet, so the distance is 0, not "no answer".

Where this comes up in exams

Skew lines and the shortest distance between them are listed in the three-dimensional geometry units of the JEE Main 2026 and JEE Advanced 2026 syllabi, and in the 2025-26 CBSE Class XII mathematics syllabus.

Checked against JEE (Main) 2026 syllabus (NTA), JEE (Advanced) 2026 syllabus and CBSE Mathematics curriculum, Classes XI-XII (2025-26). Syllabi can change from year to year, so confirm with the latest official notification for your exam.

Continue learning

All of these start from the vector form of a line's equation covered separately.