[Math] Shortest Distance between two lines in the 3D plane

cross productgeometrylinear algebramatricesvectors

Find the shortest distance between the line $x$ $=$ $2$ $-$ $t$ $y$ $=$ $-1$ $+$ $2t$ and $z$ $=$ $-1$ $+$ $t$ and the line $x$ $=$ $5$ $+$ $3s$ $y$ $=$ $0$ and $z$ $=$ $2$ $-$ $s$. Find the points on these two lines that give this shortest distance.

Using the cross product, I got the normal vector to be:

\begin{pmatrix}-2\\ -2\\ -6\end{pmatrix}

The I selected two points on the lines with $t$ $=$ $-1$:

\begin{pmatrix}3\\ -3\\ -2\end{pmatrix}

and with $s$ $=$ $1$:

\begin{pmatrix}8\\ 0\\ 1\end{pmatrix}

Therefore the distance between the these two points gave the vector:

\begin{pmatrix}-5\\ \:-3\\ \:-3\end{pmatrix}

So then I projected this vector:

$\left(\frac{\left(-5,\:-3,\:-3\right)\cdot \left(-5,\:-3,\:-3\right)}{\left(-2,\:-2,\:-6\right)\cdot \left(-2,\:-2,\:-6\right)}\right)\cdot$ $\begin{pmatrix}-2\\ -2\\ -6\end{pmatrix}$

This left me with:

$\frac{43}{\:44}\cdot$ $\begin{pmatrix}-2\\ -2\\ -6\end{pmatrix}$

Which left me with a final distance of:

$\frac{43}{44}\sqrt{44}$

But this answer isn't correct. I think I have made a mistake in my projection calculation but I am not sure where. Also, how would I find the two points that are closest together. I am also a little confused about that.

Any help would be highly appreciated!

Best Answer

You made an error right off the bat in computing the cross product of the two direction vectors: $(-1,2,1)^T\times(3,0,-1)^T = (-2,2,-6)^T$. That’s going to throw off the rest of your calculations since the dot products of any vector that has a nonzero $y$-coordinate with this vector and the one you came up with are different.

As for finding the points that are closest together, you know what the vector joining these two points is, so an easy way to do this is to set the difference of a general point on each line equal to this vector and solve for $s$ and $t$. You’ll get a system of three linear equations in two unknowns that you know must have a unique solution (unless the lines are parallel).