Distance between skew lines - correct method ? If we have two skew lines in $\mathbb R^3$, $\vec r_{1} = \vec a + \lambda\vec d_1$ and $\vec r_{2} = \vec b + \mu\vec d_2$ then at their closest point, the difference vector $\vec r_2 - \vec r_1$ is perpendicular to both $\vec r_1$ and $\vec r_2$, so:
$(\vec r_2 - \vec r_1) \cdot \vec d_1 = 0$ 
$(\vec r_2 - \vec r_1) \cdot \vec d_2 = 0$
from which we have two eqns in $\lambda$ and $\mu$ which we can solve to find the required minimum $\vec r_2 - \vec r_1$.
Is this reasoning correct ?
 A: I would have said that the difference vector $\vec{r_2} - \vec{r_1}$ must be perpendicular to both $\vec{d_1}$ and $\vec{d_2},$ which is why it is a  multiple of $\vec{d_1} \times \vec{d_2}.$
A: Yes, your reasoning is correct.
Since the difference between  the closest points is perpendicular to both $\vec{d_1}$ and $\vec{d_2}$ (that is, parallel to $\vec{d_1}\times\vec{d_2}$), we get
$$
\vec{b} - \vec{a} = \lambda\;\vec{d_1} - \mu\;\vec{d_2} + \nu\;\vec{d_1}\times\vec{d_2}
$$
Taking the dot product with $\vec{d_1}$ and $\vec{d_2}$ yields two equations in two unknowns
$$\begin{align}
(\vec{b}-\vec{a})\cdot\vec{d_1}&=\lambda\;\vec{d_1}\cdot\vec{d_1} - \mu\;\vec{d_2}\cdot\vec{d_1}\\
(\vec{b}-\vec{a})\cdot\vec{d_2}&=\lambda\;\vec{d_1}\cdot\vec{d_2} - \mu\;\vec{d_2}\cdot\vec{d_2}
\end{align}
$$
As long as $\vec{d_1}$ is not parallel to $\vec{d_2}$, these equations can be solved for $\lambda$ and $\mu$.
A: Normalized vector perpendicular to both lines:
$$
\vec{n} = {\vec{d_1} \times \vec{d_2} \over \|\vec{d_1} \times \vec{d_2}\|}
$$
shortest distance between the two lines:
$$
\mid{(\vec{a} - \vec{b}) \cdot \vec{n}}\mid
$$
