Direction cosines and direction ratios of a line
A line has a direction but no fixed "forward". If it makes angles α, β, γ with the positive x, y and z axes, then l = cos α, m = cos β, n = cos γ are its direction cosines. Reversing the line gives −l, −m, −n, which describe the same line.
- l² + m² + n² = 1.
- Direction ratios a, b, c are any numbers proportional to l, m, n. Then l = ±a/√(a² + b² + c²), and so on.
- For the line through P(x₁, y₁, z₁) and Q(x₂, y₂, z₂) the direction ratios are x₂ − x₁, y₂ − y₁, z₂ − z₁; divide by PQ for the direction cosines.
Why l² + m² + n² = 1: take a point at distance r on the line from the origin; its coordinates are (lr, mr, nr), and x² + y² + z² = r².
Vector and Cartesian equation of a line
Line through a point, parallel to a vector
Point A with position vector a, direction b. For any point P on the line, AP is parallel to b, so AP = λb. That gives the vector equation r = a + λb, λ any real number.
If a = (x₁, y₁, z₁) and b has direction ratios a, b, c, compare components: x = x₁ + λa, y = y₁ + λb, z = z₁ + λc. Remove λ to get the Cartesian equation
(x − x₁)/a = (y − y₁)/b = (z − z₁)/c.
Line through two points
Through a and b: r = a + λ(b − a); Cartesian: (x − x₁)/(x₂ − x₁) = (y − y₁)/(y₂ − y₁) = (z − z₁)/(z₂ − z₁).
Tip: read the direction ratios from the denominators and the point from the numerators, but first make the coefficients of x, y, z equal to 1. For example (3 − x)/2 means (x − 3)/(−2).
Angle between two lines
The angle between two lines is the angle between their directions b₁ and b₂ (we take the acute angle):
cos θ = |b₁·b₂| / (|b₁||b₂|).
With direction ratios a₁, b₁, c₁ and a₂, b₂, c₂: cos θ = |a₁a₂ + b₁b₂ + c₁c₂| / (√(a₁² + b₁² + c₁²) √(a₂² + b₂² + c₂²)). With direction cosines it is just |l₁l₂ + m₁m₂ + n₁n₂|.
- Perpendicular lines: a₁a₂ + b₁b₂ + c₁c₂ = 0.
- Parallel lines: a₁/a₂ = b₁/b₂ = c₁/c₂.
Skew lines
Two lines in space can be:
- Parallel — same direction, never meet (they lie in one plane).
- Intersecting — meet at one point (they lie in one plane).
- Skew — not parallel and never meet. No single plane holds both. This only happens in 3D.
Test: if the directions are not proportional, find d with the formula below. d = 0 means intersecting; d > 0 means skew.
Shortest distance between two lines
For skew lines r = a₁ + λb₁ and r = a₂ + μb₂, the shortest segment is perpendicular to both, so it lies along b₁ × b₂. The gap a₂ − a₁ projected on that direction is the distance:
d = |(a₂ − a₁)·(b₁ × b₂)| / |b₁ × b₂|.
In Cartesian form the top is the 3 × 3 determinant with rows (x₂ − x₁, y₂ − y₁, z₂ − z₁), (a₁, b₁, c₁), (a₂, b₂, c₂), and the bottom is √((b₁c₂ − b₂c₁)² + (c₁a₂ − c₂a₁)² + (a₁b₂ − a₂b₁)²).
Parallel lines
If both have direction b: d = |b × (a₂ − a₁)| / |b|. (Here b₁ × b₂ = 0, so the skew formula cannot be used.)
Board exam: shortest distance (4–5 marks), angle between lines and equation of a line through two points are asked almost every year.
Key formulas and definitions
- l² + m² + n² = 1; l = a/√(a² + b² + c²)
- Direction ratios through two points: x₂ − x₁, y₂ − y₁, z₂ − z₁
- Vector: r = a + λb; through two points: r = a + λ(b − a)
- Cartesian: (x − x₁)/a = (y − y₁)/b = (z − z₁)/c
- cosθ = |b₁·b₂| / (|b₁||b₂|)
- Perpendicular: a₁a₂ + b₁b₂ + c₁c₂ = 0; parallel: a₁/a₂ = b₁/b₂ = c₁/c₂
- Skew: d = |(a₂ − a₁)·(b₁ × b₂)| / |b₁ × b₂|
- Parallel: d = |b × (a₂ − a₁)| / |b|
Worked examples
1. Find the direction cosines of the line through A(1, 2, 3) and B(3, 4, 4).
Step 1: direction ratios = (3 − 1, 4 − 2, 4 − 3) = (2, 2, 1). Step 2: AB = √(4 + 4 + 1) = 3. Step 3: l, m, n = 2/3, 2/3, 1/3. Check: 4/9 + 4/9 + 1/9 = 1 ✓.
2. Find the direction cosines of the line (x − 3)/2 = (y + 1)/(−2) = z/1.
Step 1: direction ratios = 2, −2, 1. Step 2: √(4 + 4 + 1) = 3. Step 3: l, m, n = 2/3, −2/3, 1/3.
3. Write the vector and Cartesian equations of the line through (5, 2, −4) parallel to 3î + 2ĵ − 8k̂.
Step 1: a = 5î + 2ĵ − 4k̂, b = 3î + 2ĵ − 8k̂. Step 2: vector form r = (5î + 2ĵ − 4k̂) + λ(3î + 2ĵ − 8k̂). Step 3: Cartesian (x − 5)/3 = (y − 2)/2 = (z + 4)/(−8).
4. Find the Cartesian equation of the line through (−1, 0, 2) and (3, 4, 6).
Step 1: direction ratios = (4, 4, 4), same as (1, 1, 1). Step 2: use the first point. Step 3: (x + 1)/1 = y/1 = (z − 2)/1, i.e. x + 1 = y = z − 2.
5. Find the angle between the lines with direction ratios (3, 5, 4) and (1, 1, 2).
Step 1: b₁·b₂ = 3 + 5 + 8 = 16. Step 2: |b₁| = √50 = 5√2, |b₂| = √6. Step 3: cosθ = 16/(5√2 × √6) = 16/(10√3) = 8/(5√3) ≈ 0.924. So θ = cos⁻¹(8/(5√3)) ≈ 22.5°.
6. Find the shortest distance between r = (î + ĵ) + λ(2î − ĵ + k̂) and r = (2î + ĵ − k̂) + μ(3î − 5ĵ + 2k̂).
Step 1: a₂ − a₁ = î + 0ĵ − k̂. Step 2: b₁ × b₂ = î((−1)(2) − (1)(−5)) − ĵ((2)(2) − (1)(3)) + k̂((2)(−5) − (−1)(3)) = 3î − ĵ − 7k̂. Step 3: |b₁ × b₂| = √59. Step 4: (a₂ − a₁)·(b₁ × b₂) = 3 + 0 + 7 = 10. Step 5: d = 10/√59 ≈ 1.30 units.
7. Find the distance between the parallel lines r = (î + 2ĵ + k̂) + λ(î − ĵ + k̂) and r = (2î + ĵ − k̂) + μ(2î − 2ĵ + 2k̂).
Step 1: both directions are along b = î − ĵ + k̂ (the second is 2b). Step 2: a₂ − a₁ = î − ĵ − 2k̂. Step 3: b × (a₂ − a₁) = î((−1)(−2) − (1)(−1)) − ĵ((1)(−2) − (1)(1)) + k̂((1)(−1) − (−1)(1)) = 3î + 3ĵ + 0k̂. Step 4: |…| = 3√2, |b| = √3. Step 5: d = 3√2/√3 = √6 ≈ 2.45 units.
8. Show that the lines (x − 1)/2 = (y − 2)/3 = (z − 3)/4 and (x − 4)/5 = (y − 1)/2 = z/1 intersect.
Step 1: a₁ = (1, 2, 3), b₁ = (2, 3, 4); a₂ = (4, 1, 0), b₂ = (5, 2, 1). Step 2: a₂ − a₁ = (3, −1, −3). Step 3: b₁ × b₂ = (3·1 − 4·2, 4·5 − 2·1, 2·2 − 3·5) = (−5, 18, −11). Step 4: (a₂ − a₁)·(b₁ × b₂) = −15 − 18 + 33 = 0. Step 5: d = 0, and the lines are not parallel, so they intersect.
Common mistakes
- Reading direction ratios from (3 − x)/2 as 2. First rewrite it as (x − 3)/(−2); the ratio is −2.
- Using the points a₁, a₂ to find the angle between lines. Only the directions b₁, b₂ matter.
- Using the skew-line formula for parallel lines. There b₁ × b₂ = 0, so use d = |b × (a₂ − a₁)|/|b|.
- Forgetting the modulus in the shortest-distance formula and giving a negative distance.