Angle Between Two 3D Lines from Their Direction Vectors

December 29, 2025

Problem

explain and visualise this problem in a easy way

Explanation

We are given two lines in vector form:

Line 1: r=(3,2,4)+λ(1,2,2)Line 2: r=(5,2,0)+μ(3,2,6)\begin{aligned} \text{Line 1: } & \vec r = (3, 2, -4) + \lambda (1, 2, 2) \\ \text{Line 2: } & \vec r = (5, -2, 0) + \mu (3, 2, 6) \end{aligned}

Each line is written as:

r=a+tb\vec r = \vec a + t\,\vec b

where:

  • a\vec a is a fixed point on the line,
  • b\vec b is the direction vector of the line,
  • tt is a scalar parameter.

So for our lines:

b1=(1,2,2),b2=(3,2,6)\vec b_1 = (1, 2, 2), \quad \vec b_2 = (3, 2, 6)

The angle between the two lines is the same as the angle between their direction vectors b1\vec b_1 and b2\vec b_2.


Step 1: Recall the dot product formula

For any two vectors u\vec u and v\vec v:

uv=uvcosθ\vec u \cdot \vec v = |\vec u|\,|\vec v|\cos\theta

where θ\theta is the angle between them.

Rearranging:

cosθ=uvuv\cos\theta = \dfrac{\vec u \cdot \vec v}{|\vec u|\,|\vec v|}

We will apply this to b1\vec b_1 and b2\vec b_2.


Step 2: Compute the dot product b1b2\vec b_1 \cdot \vec b_2

b1=(1,2,2),b2=(3,2,6)\vec b_1 = (1,2,2), \quad \vec b_2 = (3,2,6)

Dot product:

b1b2=13+22+26=3+4+12=19\begin{aligned} \vec b_1 \cdot \vec b_2 &= 1\cdot 3 + 2\cdot 2 + 2\cdot 6 \\ &= 3 + 4 + 12 \\ &= 19 \end{aligned}

Step 3: Compute the magnitudes b1|\vec b_1| and b2|\vec b_2|

Magnitude of a vector (x,y,z)(x,y,z) is:

(x,y,z)=x2+y2+z2|(x,y,z)| = \sqrt{x^2 + y^2 + z^2}

For b1=(1,2,2)\vec b_1 = (1,2,2):

b1=12+22+22=1+4+4=9=3|\vec b_1| = \sqrt{1^2 + 2^2 + 2^2} = \sqrt{1 + 4 + 4} = \sqrt{9} = 3

For b2=(3,2,6)\vec b_2 = (3,2,6):

b2=32+22+62=9+4+36=49=7|\vec b_2| = \sqrt{3^2 + 2^2 + 6^2} = \sqrt{9 + 4 + 36} = \sqrt{49} = 7

Step 4: Use the cosine formula

cosθ=b1b2b1b2=193×7=1921\cos\theta = \left|\dfrac{\vec b_1 \cdot \vec b_2}{|\vec b_1|\,|\vec b_2|}\right| = \left|\dfrac{19}{3\times 7}\right| = \dfrac{19}{21}

(We take the absolute value because the angle between two lines is usually taken as the acute angle.)

So:

θ=cos1(1921)\theta = \cos^{-1}\left(\dfrac{19}{21}\right)

That is the angle between the given pair of lines.


Visual idea (what the canvas will show)

To make this easy to see:

  1. We place the tail of both direction vectors at the center of the canvas (representing the origin).
  2. We draw:
    • A cyan arrow for b1=(1,2,2)\vec b_1 = (1,2,2)
    • A pink arrow for b2=(3,2,6)\vec b_2 = (3,2,6)
  3. We draw the plane spanned by these two vectors as a soft neon grid.
  4. We highlight the angle between them with a yellow arc and display the numeric value of θ\theta.
  5. A slider lets you rotate the camera around the origin, so you can see the vectors and the angle from different viewpoints.

This helps you connect the algebraic formula (dot product) with the geometric picture (angle between arrows in 3D).

Interactive Visualization

Parameters

35.00
90.00
Angle Between Two 3D Lines from Their Direction Vectors