• Practice
  • About 19 min
  • 5 practice questions

Straight lines in space: equations, angles, intersection and shortest distance

Write vector and Cartesian equations of a line through a point with a given direction or through two points, find the angle between lines, find where two lines meet, and find the shortest distance between parallel or skew lines.

If something looks wrong, please tell us.

By the end of this lesson you can

  • Write the equation of a line in vector form (parametric and non-parametric) and in Cartesian form.
  • Find direction ratios and direction cosines of a line.
  • Find the angle between two lines and test for parallel or perpendicular lines.
  • Find the point of intersection of two lines.
  • Find the shortest distance between two parallel lines and between two skew lines.

In the plane, two lines either meet or are parallel. In space there is a third possibility: lines that neither meet nor are parallel, like a road on a flyover and a road passing underneath it at an angle. Vectors handle all three cases with the same few formulas.

Equation of a line

A line is fixed by a point A on it (position vector a) and a vector b parallel to it. A point P with position vector r lies on the line exactly when AP is parallel to b, that is r − a = tb for some scalar t. So the line is r = a + tb (parametric vector form), or (r − a) × b = 0 (non-parametric form). If A = (x₁, y₁, z₁) and b = b₁î + b₂ĵ + b₃k̂, comparing components gives the Cartesian equations (x − x₁)/b₁ = (y − y₁)/b₂ = (z − z₁)/b₃. The numbers b₁, b₂, b₃ are direction ratios; dividing them by |b| gives the direction cosines.

Through two points A(a) and B(b): the direction is b − a, so the line is r = a + t(b − a), or in Cartesian form (x − x₁)/(x₂ − x₁) = (y − y₁)/(y₂ − y₁) = (z − z₁)/(z₂ − z₁).

Worked example 1: three forms of one line

Line through (2, −1, 3) parallel to 3î + 2ĵ − k̂. Parametric: r = (2î − ĵ + 3k̂) + t(3î + 2ĵ − k̂). Non-parametric: (r − (2î − ĵ + 3k̂)) × (3î + 2ĵ − k̂) = 0. Cartesian: (x − 2)/3 = (y + 1)/2 = (z − 3)/(−1). Since |b| = √(9 + 4 + 1) = √14, the direction cosines are 3/√14, 2/√14, −1/√14.

Worked example 2: a line through two points

Line through A(1, 2, −1) and B(3, −2, 5), and the point where it crosses the xy-plane. Working: direction AB = 2î − 4ĵ + 6k̂, so (x − 1)/2 = (y − 2)/(−4) = (z + 1)/6 = t. A general point is (1 + 2t, 2 − 4t, −1 + 6t). On the xy-plane z = 0, so t = 1/6, giving x = 1 + 1/3 = 4/3 and y = 2 − 2/3 = 4/3. The line crosses at (4/3, 4/3, 0).

Angle between two lines

The acute angle θ between r = a + sb and r = c + td is the acute angle between b and d: cos θ = |b·d| / (|b||d|). The lines are perpendicular when b·d = 0 and parallel when b = λd for some scalar λ. In Cartesian form use the direction ratios: cos θ = |b₁d₁ + b₂d₂ + b₃d₃| / (√(b₁² + b₂² + b₃²) √(d₁² + d₂² + d₃²)).

Worked example 3: angles

(i) Directions 2î − ĵ + 2k̂ and î + 2ĵ + 2k̂: b·d = 2 − 2 + 4 = 4, |b| = 3, |d| = 3, so cos θ = 4/9 and θ = cos⁻¹(4/9). (ii) Directions î + 2ĵ − k̂ and 3î − ĵ + k̂: b·d = 3 − 2 − 1 = 0, so the lines are perpendicular.

Where do two lines meet?

Write a general point of each line using its own parameter, equate the x, y and z coordinates, solve two of the three equations for the parameters, and check the third. If the third is satisfied the lines meet; if not, and they are not parallel, they are skew. Two lines are coplanar if they lie in one plane: parallel or intersecting lines are coplanar, skew lines are not.

Worked example 4: an intersection

Do (x − 1)/1 = (y − 2)/2 = (z − 3)/3 and x/1 = (y − 6)/(−1) = (z − 2)/2 meet? Working: general points (1 + s, 2 + 2s, 3 + 3s) and (t, 6 − t, 2 + 2t). From x: t = 1 + s. From y: 2 + 2s = 6 − t = 5 − s, so 3s = 3, s = 1 and t = 2. Check z: 3 + 3(1) = 6 and 2 + 2(2) = 6. They agree, so the lines meet at (2, 4, 6).

Shortest distance

Skew lines are lines that are neither parallel nor intersecting. The shortest distance between two lines is the length of the segment perpendicular to both. For the skew lines r = a + sb and r = c + td, the common perpendicular is along b × d, and the distance is the projection of c − a on it: δ = |(c − a)·(b × d)| / |b × d|. The lines intersect (are coplanar) exactly when (c − a)·(b × d) = 0. For parallel lines r = a + sb and r = c + tb: δ = |(c − a) × b| / |b|.

Deciding how two lines lie

  1. Compare the directions b and d If b = λd, the lines are parallel: use |(c − a) × b| / |b|.
  2. Otherwise find b × d It is perpendicular to both lines.
  3. Compute (c − a)·(b × d) Zero: the lines intersect (coplanar).
  4. Non-zero: skew lines Distance = |(c − a)·(b × d)| / |b × d|.

Worked example 5: skew lines

Find the shortest distance between r = (î + ĵ) + s(2î − ĵ + k̂) and r = (3î + 2ĵ + k̂) + t(î + 2ĵ − 2k̂). Working: a = (1, 1, 0), b = (2, −1, 1), c = (3, 2, 1), d = (1, 2, −2). b × d = î((−1)(−2) − 1·2) − ĵ(2·(−2) − 1·1) + k̂(2·2 − (−1)·1) = 0î + 5ĵ + 5k̂, with |b × d| = 5√2. c − a = (2, 1, 1), and (c − a)·(b × d) = 0 + 5 + 5 = 10. So δ = 10/(5√2) = √2 units. Since this is not zero, the lines are skew.

Worked example 6: parallel lines

Find the distance between r = (î + 2ĵ − k̂) + s(2î + ĵ + 2k̂) and r = (3î − ĵ + k̂) + t(2î + ĵ + 2k̂). Working: c − a = 2î − 3ĵ + 2k̂ and b = 2î + ĵ + 2k̂ with |b| = 3. (c − a) × b = î((−3)(2) − 2·1) − ĵ(2·2 − 2·2) + k̂(2·1 − (−3)·2) = −8î + 0ĵ + 8k̂, of length 8√2. So δ = 8√2/3 units.

Line: r = a + tb, or (x − x₁)/b₁ = (y − y₁)/b₂ = (z − z₁)/b₃. Skew lines: δ = |(c − a)·(b × d)| / |b × d|. Parallel lines: δ = |(c − a) × b| / |b|.

— Lines in space

Key takeaways: a point and a direction fix a line; read direction ratios from the denominators of the Cartesian form. The angle between lines is the angle between their directions. Equate general points to find an intersection, and use the triple product formula for the shortest distance between skew lines.

Check your understanding

  1. 1. Which are the Cartesian equations of the line through (1, −2, 3) parallel to 2î − ĵ + 4k̂?

    1. (x − 2)/1 = (y + 1)/(−2) = (z − 4)/3
    2. (x + 1)/2 = (y − 2)/(−1) = (z + 3)/4
    3. (x − 1)/2 = (y + 2)/(−1) = (z − 3)/4
    4. (x − 1)/2 = (y + 2)/1 = (z − 3)/4
    Show answer

    Answer: C. The form is (x − x₁)/b₁ = (y − y₁)/b₂ = (z − z₁)/b₃ with (x₁, y₁, z₁) = (1, −2, 3) and (b₁, b₂, b₃) = (2, −1, 4).

  2. 2. Lines with directions î + 2ĵ − k̂ and 3î − ĵ + k̂ are

    1. parallel
    2. perpendicular
    3. inclined at π/3
    4. the same line
    Show answer

    Answer: B. The dot product of the directions is 3 − 2 − 1 = 0, so the lines are perpendicular.

  3. 3. What is the acute angle between lines with directions î + ĵ and ĵ + k̂?

    1. π/3
    2. π/4
    3. π/6
    4. π/2
    Show answer

    Answer: A. cos θ = |b·d|/(|b||d|) = 1/(√2 × √2) = 1/2, so θ = π/3.

  4. 4. Which formula gives the shortest distance between the skew lines r = a + sb and r = c + td?

    1. |(c − a) × b| / |b|
    2. |c − a|
    3. |b·d| / (|b||d|)
    4. |(c − a)·(b × d)| / |b × d|
    Show answer

    Answer: D. The common perpendicular is along b × d, and the distance is the projection of c − a on it: |(c − a)·(b × d)| / |b × d|. The first formula is for parallel lines.

  5. 5. Where does the line through (2, 1, −1) and (4, 3, 1) cross the xy-plane?

    1. (2, 1, 0)
    2. (3, 2, 0)
    3. (4, 3, 0)
    4. (6, 5, 0)
    Show answer

    Answer: B. Direction (2, 2, 2); general point (2 + 2t, 1 + 2t, −1 + 2t). z = 0 gives t = 1/2, so the point is (3, 2, 0).

Privacy · Terms · Refunds · Delivery