Angle Between Two Lines in Space: 3D Formula Guide
Two lines in 3D may intersect or be skew, but either way the angle between them is defined through their direction vectors. If the direction vectors are d1 and d2, the angle θ between the lines satisfies cos θ = |d1 · d2| / (|d1| |d2|).
The modulus in the numerator forces the acute value: by convention the angle between two lines always lies between 0° and 90°. This single formula handles intersecting lines, parallel lines and skew lines alike.
Key Concepts
- Direction vectors: for a line in symmetric form (x − x1)/a = (y − y1)/b = (z − z1)/c, the direction vector is (a, b, c).
- The angle between lines equals the angle between their direction vectors, taken acute: 0° ≤ θ ≤ 90°.
- Parallel lines: d1 × d2 = 0 (equivalently d1 = k·d2 for some scalar k), giving θ = 0°.
- Perpendicular lines: d1 · d2 = 0, giving θ = 90°. The lines need not intersect to be called perpendicular in 3D.
- Skew lines, which are non-parallel and non-intersecting, still have a well-defined angle via their direction vectors.
Formulas
- cos θ = |a1a2 + b1b2 + c1c2| / (√(a1² + b1² + c1²) √(a2² + b2² + c2²)), where (a1, b1, c1) and (a2, b2, c2) are the direction vectors.
- In terms of direction cosines: cos θ = |l1l2 + m1m2 + n1n2|.
- Parallel condition: a1/a2 = b1/b2 = c1/c2. Perpendicular condition: a1a2 + b1b2 + c1c2 = 0.
Worked Example
Find the angle between lines with direction vectors (2, 1, −2) and (1, −2, 2).
- Dot product: 2×1 + 1×(−2) + (−2)×2 = 2 − 2 − 4 = −4. Take the modulus: 4.
- |d1| = √(4 + 1 + 4) = √9 = 3. |d2| = √(1 + 4 + 4) = √9 = 3.
- cos θ = 4 / (3 × 3) = 4/9 ≈ 0.444.
- θ = arccos(4/9) ≈ 63.6°.
- Sanity check: the raw dot product is negative, so the angle between the vectors themselves is obtuse, about 116.4°; the acute angle between the lines is 180° − 116.4° = 63.6°. Correct.
Common Misconceptions
- The angle can be obtuse. For lines, unlike for vectors, we always report the acute angle from 0° to 90°, thanks to the modulus.
- Skew lines have no angle between them. They do — the angle is computed from direction vectors, which need no intersection point.
- Perpendicular lines must intersect. In 3D, lines can be perpendicular, meaning their direction vectors are at 90°, while being skew and never meeting.
Real-World Applications
- Checking clearances between pipes, beams and cables in 3D CAD models.
- Robotics: angles between arm segments and planned paths.
- Crystallography: angles between crystal edges and lattice directions.
- Computer graphics: comparing orientations of edges and rays.
The angle between two lines comes from their direction vectors: cos θ = |d1 · d2| / (|d1| |d2|), always acute. Remember the modulus, the parallel and perpendicular tests, and that skew lines have angles too.
Related blogs
- Scalars and Vectors: Difference Explained with Examples
- Types of Vectors: Zero, Unit, Equal & More Explained
- Addition and Subtraction of Vectors: Explained with Examples
- Scalar Multiplication of Vectors: Scaling Made Simple
- Section Formula in Vector Form: Derivation and Examples
- Dot Scalar Product: Concepts, Formulas and Examples