Problem 242
Medium Lines

Derive the formula for the shortest distance between the…

Derive the formula for the shortest distance between the non-parallel lines $\frac{x-x_1}{l_1}=\frac{y-y_1}{m_1}=\frac{z-z_1}{n_1}\quad\text{and}\quad\frac{x-x_2}{l_2}=\frac{y-y_2}{m_2}=\frac{z-z_2}{n_2} $.

Explanation of Method

Derivation of the formula for the shortest distance between two non-parallel lines.

Step 1: Decomposition

Let $\vec n=\vec p_1\times\vec p_2\ne\vec0$. Then $\vec p_1,\vec p_2,\vec n$ form a basis, so

\[ \overrightarrow{M_1M_2}=a\vec p_1+b\vec p_2+\vec u,\qquad \vec u\parallel\vec n,\quad |\vec u|=\frac{|\overrightarrow{M_1M_2}\cdot\vec n|}{|\vec n|}. \]

Step 2: Minimisation

For $A=M_1+s\vec p_1\in\ell_1$ and $B=M_2+t\vec p_2\in\ell_2$: \[\overrightarrow{AB}=\vec u+\underbrace{(a-s)\vec p_1+(b+t)\vec p_2}_{\perp\ \vec u}\ \Longrightarrow\ |AB|^2=|\vec u|^2+|(a-s)\vec p_1+(b+t)\vec p_2|^2\ge|\vec u|^2 .\]

Equality holds exactly for $s=a$, $t=-b$. Then $AB$ is the common perpendicular.

\[d=\frac{\left|\begin{vmatrix}x_2-x_1&y_2-y_1&z_2-z_1\\l_1&m_1&n_1\\l_2&m_2&n_2\end{vmatrix}\right|}{|\vec p_1\times\vec p_2|}\]

Here

\[ |\vec p_1\times\vec p_2|^2=(m_1n_2-m_2n_1)^2+(n_1l_2-n_2l_1)^2+(l_1m_2-l_2m_1)^2 . \]

$M_1$ $M_2$ $d$ $\ell_1$ $\ell_2$
The common perpendicular (dashed) is parallel to $\vec p_1\times\vec p_2$; $d$ is the projection of $\overrightarrow{M_1M_2}$ (dotted) onto that direction.

Result

\[\boxed{\,d=\frac{\left|\begin{vmatrix}x_2-x_1&y_2-y_1&z_2-z_1\\l_1&m_1&n_1\\l_2&m_2&n_2\end{vmatrix}\right|}{|\vec p_1\times\vec p_2|}\,}\]

Remark

The source's step 5 contains a garbled expression (“$(\lambda_1+s-\lambda_1)\vec p_1+\ldots$”). The argument above replaces it with a complete version. Special cases: numerator $=0$ means the lines intersect ($d=0$); $\vec p_1\parallel\vec p_2$ calls for the point–line distance (Problem 241).