Shortest Distance between two lines in the 3D plane

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!

• $(-1,2,1)\times(3,0,-1)\ne(-2,-2,-6)$.
– amd
Apr 6 '18 at 21:50
• Thank you! I guess I missed the sign. So it should be $(-2, 2, -6)$? But this will still give me the same answer eventually because of the squaring. So is it that I have a problem somewhere else? Apr 6 '18 at 21:57
• Why do you think you’d get the same answer? The projections onto the correct vector and your incorrect one have completely different lengths.
– amd
Apr 6 '18 at 22:00
• Two two vectors are the same length, but their dot products with the vector that you’re projecting onto them—the numerators—are quite different.
– amd
Apr 6 '18 at 22:54
• There is indeed a typo in your projection formula. If $\mathbf n, \mathbf n_1, \mathbf n_2$ form an orthogonal basis, and $\mathbf u = \lambda \mathbf n +\lambda_1 \mathbf n_1 + \lambda_2 \mathbf n_2$, then $$\mathbf u .\! \mathbf n = \lambda \mathbf n .\! \mathbf n,\\ \lambda = \frac {\mathbf u .\! \mathbf n} {\mathbf n .\! \mathbf n}.$$ It can be easily verified that $\lambda$ will be the same for any vector $\mathbf u$ that has its endpoints on the two lines. Apr 7 '18 at 17:00

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).