# 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 ?

-

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}.$

-
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$.
@ukmaths:yes, I should have answered the stated question: your reasoning is correct. That being said, I was simply writing the equations in a form that explicitly deals with the knowns ($\vec{a}$, $\vec{b}$, $\vec{d_1}$, and $\vec{d_2}$) and the unknowns ($\lambda$ and $\mu$). I also thought it worth mentioning that if $\vec{d_1}$ and $\vec{d_2}$ are parallel, then no solution exists (which is in accord with the geometry that no closest point exists). –  robjohn Jul 31 '11 at 11:50