Three-Dimensional Geometry • Topic 3 of 4

Angle Between Lines & Shortest Distance

Once lines are written as "point plus direction", every relationship between two of them is governed by their direction vectors $\vec b_1$ and $\vec b_2$. Two questions dominate the exam: what is the angle between the lines, and — if they never meet — how far apart are they?

Angle between two lines

The angle $\theta$ between two lines is the angle between their direction vectors. Using the dot product,

$$\cos\theta=\dfrac{|\vec b_1\cdot\vec b_2|}{|\vec b_1|\,|\vec b_2|}.$$

The absolute value is deliberate: it selects the acute angle, which is the conventional answer for an undirected line. In direction-ratio terms, if $\vec b_1=(a_1,b_1,c_1)$ and $\vec b_2=(a_2,b_2,c_2)$,

$$\cos\theta=\dfrac{|a_1a_2+b_1b_2+c_1c_2|}{\sqrt{a_1^2+b_1^2+c_1^2}\,\sqrt{a_2^2+b_2^2+c_2^2}}.$$

If the lines are given by direction cosines $(l_1,m_1,n_1)$ and $(l_2,m_2,n_2)$, the denominators are $1$ and the formula simplifies to $\cos\theta=|l_1l_2+m_1m_2+n_1n_2|$.

Parallel and perpendicular conditions

Two special cases fall straight out of the dot and cross products:

RelationVector testRatio test
Perpendicular$\vec b_1\cdot\vec b_2=0$$a_1a_2+b_1b_2+c_1c_2=0$
Parallel$\vec b_1\times\vec b_2=\vec 0$$\dfrac{a_1}{a_2}=\dfrac{b_1}{b_2}=\dfrac{c_1}{c_2}$

Perpendicular lines need not intersect — in space, "perpendicular" only constrains the directions.

Shortest distance between two skew lines

Two lines in space are skew if they are neither parallel nor intersecting. The shortest distance between them is measured along their common perpendicular. For $\vec r=\vec a_1+\lambda\vec b_1$ and $\vec r=\vec a_2+\mu\vec b_2$,

$$d=\dfrac{\big|(\vec b_1\times\vec b_2)\cdot(\vec a_2-\vec a_1)\big|}{|\vec b_1\times\vec b_2|}.$$

The idea: $\vec b_1\times\vec b_2$ points along the common perpendicular, so projecting the gap vector $\vec a_2-\vec a_1$ onto that unit direction gives the shortest distance. The numerator is the scalar triple product $[\vec b_1\ \vec b_2\ (\vec a_2-\vec a_1)]$.

Intersecting / coplanar lines

If $d=0$ the two lines meet, because the gap vector lies in the plane of the two directions. Hence the coplanarity (intersection) condition is

$$(\vec b_1\times\vec b_2)\cdot(\vec a_2-\vec a_1)=0,$$

equivalently the determinant with rows $\vec a_2-\vec a_1$, $\vec b_1$, $\vec b_2$ vanishes. Non-parallel lines satisfying this actually intersect.

Distance between parallel lines

When the lines are parallel, $\vec b_1\times\vec b_2=\vec 0$ and the skew formula breaks down. Take a single common direction $\vec b$; the distance between $\vec r=\vec a_1+\lambda\vec b$ and $\vec r=\vec a_2+\mu\vec b$ is the perpendicular component of the gap vector:

$$d=\dfrac{|\vec b\times(\vec a_2-\vec a_1)|}{|\vec b|}.$$

Deeper Insight — dot product for angles, cross product for distances. The two tools split the work cleanly. The dot product measures alignment, so it answers every "angle / perpendicular / parallel" question. The cross product produces a vector perpendicular to both directions, which is exactly what a shortest-distance measurement needs. Reading $d=0$ as "the lines are coplanar" turns the intimidating intersection problem into one tidy scalar-triple-product check, and recognising when $\vec b_1\times\vec b_2=\vec 0$ (parallel case) tells you to switch formulas before you ever divide by zero. Decide first whether the lines are parallel; everything else follows.

A 3D axis frame showing two skew lines that neither meet nor run parallel, joined by their common perpendicular which marks the shortest distance, with right-angle ticks at both feet and the angle between the line directions indicated. Skew Lines & Shortest Distance x y z L₁ L₂ shortest distance θ d = |(b₁ × b₂)·(a₂ − a₁)| / |b₁ × b₂|    cosθ = |b₁·b₂| / (|b₁||b₂|)
1
Worked Example
Find the angle between lines with directions $\vec b_1=\hat i+\hat j+\hat k$ and $\vec b_2=\hat i-\hat j+\hat k$.
Solution
  1. $\vec b_1\cdot\vec b_2=(1)(1)+(1)(-1)+(1)(1)=1$.
  2. $|\vec b_1|=|\vec b_2|=\sqrt3$.
  3. $\cos\theta=\dfrac{|1|}{\sqrt3\cdot\sqrt3}=\dfrac13$.

Answer: $\theta=\cos^{-1}\!\left(\tfrac13\right)$.

2
Worked Example
Show that the lines with directions $\hat i+\hat j$ and $\hat i-\hat j$ are perpendicular.
Solution
  1. Compute the dot product: $(1)(1)+(1)(-1)+0=0$.
  2. A zero dot product means $\theta=90^\circ$.

Answer: The lines are perpendicular, since $\vec b_1\cdot\vec b_2=0$.

3
Worked Example
Are the lines with directions $2\hat i+4\hat j+6\hat k$ and $\hat i+2\hat j+3\hat k$ parallel?
Solution
  1. Check proportionality: $\tfrac21=\tfrac42=\tfrac63=2$.
  2. So $\vec b_1=2\vec b_2$, giving $\vec b_1\times\vec b_2=\vec 0$.

Answer: Yes — one direction is a scalar multiple of the other, so the lines are parallel.

4
Worked Example
State the shortest-distance formula and the condition for two lines to intersect.
Solution
  1. The shortest distance projects the gap onto the common perpendicular $\vec b_1\times\vec b_2$.
  2. Intersection is the case where that projection is zero.

Answer: $d=\dfrac{|(\vec b_1\times\vec b_2)\cdot(\vec a_2-\vec a_1)|}{|\vec b_1\times\vec b_2|}$; the lines intersect (are coplanar) when $(\vec b_1\times\vec b_2)\cdot(\vec a_2-\vec a_1)=0$.

5
Worked Example
Find the angle between the lines with direction ratios $(1,2,2)$ and $(2,2,1)$.
Solution
  1. Dot of ratios: $(1)(2)+(2)(2)+(2)(1)=2+4+2=8$.
  2. Magnitudes: $\sqrt{1+4+4}=3$ and $\sqrt{4+4+1}=3$.
  3. $\cos\theta=\dfrac{8}{3\cdot 3}=\dfrac89$.

Answer: $\theta=\cos^{-1}\!\left(\tfrac89\right)$.

6
Worked Example
Find $\lambda$ so that the lines with direction ratios $(2,\lambda,3)$ and $(1,-1,2)$ are perpendicular.
Solution
  1. Perpendicular $\Rightarrow$ dot product $=0$.
  2. $(2)(1)+(\lambda)(-1)+(3)(2)=0$.
  3. $2-\lambda+6=0\Rightarrow \lambda=8$.

Answer: $\lambda=8$.

7
Worked Example
Find the angle between the lines $\dfrac{x-2}{2}=\dfrac{y-1}{5}=\dfrac{z+3}{-3}$ and $\dfrac{x+2}{-1}=\dfrac{y-4}{8}=\dfrac{z-5}{4}$.
Solution
  1. DRs: $\vec b_1=(2,5,-3)$, $\vec b_2=(-1,8,4)$.
  2. $\vec b_1\cdot\vec b_2=(2)(-1)+(5)(8)+(-3)(4)=-2+40-12=26$.
  3. $|\vec b_1|=\sqrt{4+25+9}=\sqrt{38}$, $|\vec b_2|=\sqrt{1+64+16}=\sqrt{81}=9$.
  4. $\cos\theta=\dfrac{26}{9\sqrt{38}}$.

Answer: $\theta=\cos^{-1}\!\left(\dfrac{26}{9\sqrt{38}}\right)$.

8
Worked Example
Show that the line through $(1,-1,2)$ and $(3,4,-2)$ is perpendicular to the line through $(0,3,2)$ and $(3,5,6)$.
Solution
  1. First direction: $(3-1,\ 4-(-1),\ -2-2)=(2,5,-4)$.
  2. Second direction: $(3-0,\ 5-3,\ 6-2)=(3,2,4)$.
  3. Dot product: $(2)(3)+(5)(2)+(-4)(4)=6+10-16=0$.

Answer: The dot product is $0$, so the two lines are perpendicular.

9
Worked Example
Find the shortest distance between $\vec r=(\hat i+2\hat j+\hat k)+\lambda(\hat i-\hat j+\hat k)$ and $\vec r=(2\hat i-\hat j-\hat k)+\mu(2\hat i+\hat j+2\hat k)$.
Solution
  1. $\vec a_1=(1,2,1)$, $\vec b_1=(1,-1,1)$; $\vec a_2=(2,-1,-1)$, $\vec b_2=(2,1,2)$.
  2. $\vec b_1\times\vec b_2=\big((-1)(2)-(1)(1),\ (1)(2)-(1)(2),\ (1)(1)-(-1)(2)\big)=(-3,0,3)$.
  3. $|\vec b_1\times\vec b_2|=\sqrt{9+0+9}=3\sqrt2$.
  4. $\vec a_2-\vec a_1=(1,-3,-2)$.
  5. $(\vec b_1\times\vec b_2)\cdot(\vec a_2-\vec a_1)=(-3)(1)+0+3(-2)=-9$.
  6. $d=\dfrac{|-9|}{3\sqrt2}=\dfrac{9}{3\sqrt2}=\dfrac{3}{\sqrt2}$.

Answer: $d=\dfrac{3}{\sqrt2}=\dfrac{3\sqrt2}{2}$ units.

10
Worked Example
Show that the lines $\dfrac{x-1}{2}=\dfrac{y-2}{3}=\dfrac{z-3}{4}$ and $\dfrac{x-4}{5}=\dfrac{y-1}{2}=\dfrac{z}{1}$ intersect (are coplanar).
Solution
  1. $\vec a_1=(1,2,3)$, $\vec b_1=(2,3,4)$; $\vec a_2=(4,1,0)$, $\vec b_2=(5,2,1)$.
  2. $\vec a_2-\vec a_1=(3,-1,-3)$.
  3. $\vec b_1\times\vec b_2=\big((3)(1)-(4)(2),\ (4)(5)-(2)(1),\ (2)(2)-(3)(5)\big)=(-5,18,-11)$.
  4. $(\vec b_1\times\vec b_2)\cdot(\vec a_2-\vec a_1)=(-5)(3)+(18)(-1)+(-11)(-3)=-15-18+33=0$.
  5. The triple product is zero and the lines are not parallel.

Answer: The shortest distance is $0$, so the lines are coplanar and intersect.

11
Worked Example
Find the distance between the parallel lines $\vec r=(\hat i+\hat j)+\lambda(2\hat i-\hat j+\hat k)$ and $\vec r=(2\hat i+\hat j-\hat k)+\mu(2\hat i-\hat j+\hat k)$.
Solution
  1. Common direction $\vec b=(2,-1,1)$, $|\vec b|=\sqrt{4+1+1}=\sqrt6$.
  2. Gap vector $\vec a_2-\vec a_1=(2-1,\ 1-1,\ -1-0)=(1,0,-1)$.
  3. $\vec b\times(\vec a_2-\vec a_1)=\big((-1)(-1)-(1)(0),\ (1)(1)-(2)(-1),\ (2)(0)-(-1)(1)\big)=(1,3,1)$.
  4. $|\vec b\times(\vec a_2-\vec a_1)|=\sqrt{1+9+1}=\sqrt{11}$.
  5. $d=\dfrac{\sqrt{11}}{\sqrt6}$.

Answer: $d=\dfrac{\sqrt{11}}{\sqrt6}=\sqrt{\dfrac{11}{6}}$ units.

Key Points

  • The angle between two lines is the angle between their directions: $\cos\theta=\dfrac{|\vec b_1\cdot\vec b_2|}{|\vec b_1||\vec b_2|}$ (absolute value gives the acute angle).
  • In ratio form, $\cos\theta=\dfrac{|a_1a_2+b_1b_2+c_1c_2|}{\sqrt{a_1^2+b_1^2+c_1^2}\,\sqrt{a_2^2+b_2^2+c_2^2}}$; with direction cosines the denominators are $1$.
  • Perpendicular $\iff \vec b_1\cdot\vec b_2=0$; parallel $\iff \vec b_1\times\vec b_2=\vec 0$ (proportional ratios).
  • Skew lines are neither parallel nor intersecting; shortest distance $d=\dfrac{|(\vec b_1\times\vec b_2)\cdot(\vec a_2-\vec a_1)|}{|\vec b_1\times\vec b_2|}$.
  • $d=0$ (i.e. $(\vec b_1\times\vec b_2)\cdot(\vec a_2-\vec a_1)=0$) means the lines are coplanar; non-parallel coplanar lines intersect.
  • Parallel lines use $d=\dfrac{|\vec b\times(\vec a_2-\vec a_1)|}{|\vec b|}$, since the skew formula divides by zero there.
  • Strategy: decide parallel-or-not first (cross product), then use the dot product for angles and the cross product for distances.
Tap an option to check your answer0 / 4
Q1.Two lines are perpendicular when their direction vectors satisfy:
Explanation: Zero dot product.
Q2.The cosine of the angle between lines uses:
Explanation: Dot-product angle formula.
Q3.Skew lines intersect when the shortest distance is:
Explanation: $d=0$ means coplanar/intersecting.
Q4.Lines with directions $2\hat i+4\hat j+6\hat k$ and $\hat i+2\hat j+3\hat k$ are:
Explanation: One is a scalar multiple of the other.