Three Dimensional Coordinate System
3.0 Distance and Angle between lines and points.
3.1 Condition for perpendicularity
3.2 Condition for parallelism
3.3 Co-planarity of two lines
3.4 Shortest distance between two lines
3.5 Distance between two skew lines
3.6 Distance between parallel lines
3.7 Perpendicular distance of a point from a line
3.8 Image of a point in a straight line
3.0 Distance and Angle between lines and points.
3.2 Condition for parallelism
3.3 Co-planarity of two lines
3.4 Shortest distance between two lines
3.5 Distance between two skew lines
3.6 Distance between parallel lines
3.7 Perpendicular distance of a point from a line
3.8 Image of a point in a straight line
Let us assume the equation of two lines in vector form i.e., $${L_1} \equiv \overrightarrow r = \overrightarrow a + \lambda \overrightarrow b $$ and $${L_2} \equiv \overrightarrow {{r}} = \overrightarrow {{a'}} + \lambda \overrightarrow {{b'}} $$
From the equation of two lines, we can say that the line ${L_1}$ is in the direction of $\overrightarrow b $ and the line ${L_2}$ is in the direction of $\overrightarrow {{b'}} $.
Let us assume the angle between the two lines ${L_1}$ and ${L_2}$ be $\theta $ which means it is also the angle between $\overrightarrow b $ and $\overrightarrow {{b'}} $ and can be calculated as
$$\begin{equation} \begin{aligned} \overrightarrow b .\overrightarrow {{b'}} = \left| {\overrightarrow b } \right|\left| {\overrightarrow {{b'}} } \right|\cos \theta \\ \Rightarrow \cos \theta = \frac{{\overrightarrow b .\overrightarrow {{b'}} }}{{\left| {\overrightarrow b } \right|\left| {\overrightarrow {{b'}} } \right|}} \\\end{aligned} \end{equation} $$
Now, let us assume the equation of two lines in cartesian form i.e., $$\begin{equation} \begin{aligned} \frac{{x - {x_1}}}{{{a_1}}} = \frac{{y - {y_1}}}{{{b_1}}} = \frac{{z - {z_1}}}{{{c_1}}} \\ \frac{{x - {x_2}}}{{{a_2}}} = \frac{{y - {y_2}}}{{{b_2}}} = \frac{{z - {z_2}}}{{{c_2}}} \\\end{aligned} \end{equation} $$
From the above two equations, we can write the parallel vectors of the lines as $$\begin{equation} \begin{aligned} \overrightarrow b = {a_1}\widehat i + {b_1}\widehat j + {c_1}\widehat k \\ \overrightarrow {{b'}} = {a_2}\widehat i + {b_2}\widehat j + {c_2}\widehat k \\\end{aligned} \end{equation} $$
Therefore, $$\overrightarrow b .\overrightarrow {{b'}} = {a_1}{a_2} + {b_1}{b_2} + {c_1}{c_2}$$ and $$\begin{equation} \begin{aligned} \left| {\overrightarrow b } \right| = \sqrt {{a_1}^2 + {b_1}^2 + {c_1}^2} \\ \left| {\overrightarrow {{b'}} } \right| = \sqrt {{a_2}^2 + {b_2}^2 + {c_2}^2} \\\end{aligned} \end{equation} $$
Therefore, the angle between two lines is $$\cos \theta = \frac{{\overrightarrow b .\overrightarrow {{b'}} }}{{\left| {\overrightarrow b } \right|\left| {\overrightarrow {{b'}} } \right|}}$$
$$ \Rightarrow \cos \theta = \frac{{{a_1}{a_2} + {b_1}{b_2} + {c_1}{c_2}}}{{\sqrt {{a_1}^2 + {b_1}^2 + {c_1}^2} \sqrt {{a_2}^2 + {b_2}^2 + {c_2}^2} }}$$
Note: If instead of direction ratios for the lines ${L_1}$ and ${L_2}$, direction cosines are given i.e., ${l_1},{m_1},{n_1}$ for line ${L_1}$ and ${l_2},{m_2},{n_2}$ for line ${L_2}$, then the angle between the two lines is $$\begin{equation} \begin{aligned} \cos \theta = \frac{{{l_1}{l_2} + {m_1}{m_2} + {n_1}{n_2}}}{{\sqrt {{l_1}^2 + {m_1}^2 + {n_1}^2} \sqrt {{l_2}^2 + {m_2}^2 + {n_2}^2} }} \\ \cos \theta = \left| {{l_1}{l_2} + {m_1}{m_2} + {n_1}{n_2}} \right|{\text{ }}\left( {\because {l_1}^2 + {m_1}^2 + {n_1}^2 = 1 = {l_2}^2 + {m_2}^2 + {n_2}^2} \right) \\\end{aligned} \end{equation} $$