📘 CodingMarble Learn

Three Dimensional Geometry

A line in space is fixed by one point on it and its direction. Its direction cosines l, m, n satisfy l² + m² + n² = 1; any numbers in the same ratio are direction ratios, and through two points they are (x₂ − x₁, y₂ − y₁, z₂ − z₁). Vector equation: r = a + λb. Cartesian equation: (x − x₁)/a = (y − y₁)/b = (z − z₁)/c. The angle between two lines is the angle between their directions: cosθ = |b₁·b₂|/(|b₁||b₂|). Two lines in space are parallel, intersecting or skew. The shortest distance between skew lines is d = |(a₂ − a₁)·(b₁ × b₂)|/|b₁ × b₂|; for parallel lines d = |b × (a₂ − a₁)|/|b|; d = 0 means they meet.

🎬 Step-by-step story

  1. Take two points A and B in space. The line through them leans at angles α, β, γ to the axes. B − A gives the direction ratios. Divide by the length AB and you get the direction cosines l, m, n.
  2. To describe a line you need one point on it (a) and its direction (b). Every point on the line is a + λb for some number λ. Change λ and the point slides along the line.
  3. The angle between two lines is simply the angle between their direction arrows b₁ and b₂. Use the dot product: cosθ = |b₁·b₂| / (|b₁||b₂|).
  4. In a flat page, two lines are either parallel or they cross. In space there is a third kind: skew lines. They never meet and they are not parallel, like a flyover and the road under it.
  5. The shortest distance between two skew lines is along the one segment that is at right angles to both. Its direction is b₁ × b₂. Project a₂ − a₁ on it to get d.
  6. Your turn. Pick any scene and change it. Or open a solved example and reveal it one line at a time.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Why can a line have two sets of direction cosines?

A line can be read in either direction, so (l, m, n) and (−l, −m, −n) describe the same line. In step 1 move B to the other side of A: the line stays the same but every sign flips.

What does λ mean in r = a + λb?

λ is how many steps of b you take from the point a. λ = 0 is a itself, negative λ goes backwards. Move the λ slider in step 2.

Why do we take the modulus in the angle formula?

Two lines make two angles, θ and 180° − θ. The modulus gives the acute one. Pick any pair in step 3.

How are skew lines possible if every two lines seem to cross?

On paper they do, but in space one line can pass above the other. Pick 'Skew' in step 4 and turn the scene.

Why is the shortest segment perpendicular to both lines?

If it were slanted to one line, sliding its end along that line would make it shorter. Step 5 shows the green segment meeting both at right angles.

Why can't I use the skew formula for parallel lines?

For parallel lines b₁ × b₂ = 0, so the formula divides by zero. Tick 'Parallel lines' in step 5 to see the other formula.

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.

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₂|.

Skew lines

Two lines in space can be:

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

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

Practice quiz

1. The direction ratios of the line through (1, 0, 2) and (3, 1, 5) are:
2. Vector equation of a line through point a parallel to b is:
3. Lines with direction ratios (1, 2, 3) and (3, 0, −1) are:
4. Two lines that are neither parallel nor intersecting are called:
5. If the shortest distance between two non-parallel lines is 0, the lines:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

What is the difference between direction cosines and direction ratios of a line?

Direction cosines are the cosines of the angles with the axes and satisfy l² + m² + n² = 1. Direction ratios are any three numbers proportional to them, like the differences of coordinates of two points.

How do you check whether two lines are skew?

If the directions are not proportional, compute (a₂ − a₁)·(b₁ × b₂). If it is 0 the lines intersect; if not, they are skew.

Is the plane part of CBSE Class 12 3D geometry for 2026-27?

The current CBSE syllabus for this unit covers lines: direction cosines, equations, angle between lines, skew lines and shortest distance. Planes are not in the list for this session.

Where this is taught

Canada (Ontario)Grade 12C. Geometry and Algebra of Vectors
ItalySecondaria di secondo grado – classe 5ª (esame di Stato)Geometry
ItalySecondaria di secondo grado – classe 5ª (esame di Stato)Geometry
ItalySecondaria di secondo grado – classe 5ª (esame di Stato)Geometry
CBSE (India)Class 12Vectors and Three-Dimensional Geometry
England (GCSE, A level)Year 12F Further vectors (part 1)
England (GCSE, A level)Year 13F Further vectors (part 2)
South Korea고등학교 2학년Space figures and coordinates
South Korea고등학교 2학년Vectors
South Korea고등학교 3학년Space figures and coordinates
Germany (Bavaria)Jahrgangsstufe 13Lines and planes in space
FranceTerminaleAlgebra and geometry
Russia11 классVectors and coordinates
Russia11 классVectors and coordinates in space
China高二Ch.1 Spatial vectors and solid geometry

Learn first

Related lessons

All Maths lessons