Math Relative position of lines Angle between two lines

# Angle between two lines

The angle between two lines is calculated similarly as the angle between two vectors.

!

### Remember

In contrast to vectors, the angle between two lines always discribes the angle less than 90°.

Two lines are given:

$\text{g: } \vec{x} = \vec{u} + r \cdot \vec{a}$

$\text{h: } \vec{x} = \vec{v} + s \cdot \vec{b}$

For determining the angle the direction vectors of the lines are used:

$\cos(\gamma) = \frac{|\vec{a}\cdot\vec{b}|}{|\vec{a}|\cdot|\vec{b}|}$

$\gamma = \cos^{-1}\left(\frac{|\vec{a}\cdot\vec{b}|}{|\vec{a}|\cdot|\vec{b}|}\right)$
i

### Method

1. Calculate the scalar product of the direction vectors
2. Calculate the magnitude of the direction vectors
3. Insert results into the formula

### Example

$\text{g: } \vec{x} = \begin{pmatrix} 10 \\ 9 \\ 7 \end{pmatrix} + r \cdot \begin{pmatrix} 9 \\ 8 \\ 7 \end{pmatrix}$

$\text{h: } \vec{x} = \begin{pmatrix} 4 \\ 4 \\ 6 \end{pmatrix} + s \cdot \begin{pmatrix} 1 \\ 1 \\ 2 \end{pmatrix}$

1. #### Calculate scalar product

$\vec{a}\cdot\vec{b}$ $=\begin{pmatrix}9 \\ 8 \\ 7 \end{pmatrix}\cdot\begin{pmatrix}1 \\ 1 \\ 2\end{pmatrix}$ $=9\cdot1+8\cdot1+7\cdot2$ $=31$
2. #### Calculate magnitude of the direction vectors

$|\vec{a}|=\sqrt{9^2+8^2+7^2}$ $=\sqrt{194}$

$|\vec{b}|=\sqrt{1^2+1^2+2^2}$ $=\sqrt{6}$
3. #### Insert results into the formula

$\cos(\gamma) = \frac{|\vec{a}\cdot\vec{b}|}{|\vec{a}|\cdot|\vec{b}|}$

$\cos(\gamma) = \frac{31}{\sqrt{194}\cdot\sqrt{6}}$

$\gamma = \cos^{-1}\left(\frac{31}{\sqrt{194}\cdot\sqrt{6}}\right)$ $\approx24.68°$