[Math] How to find the distance between two non-parallel lines

3danalytic geometrylinear algebravectors

I am tasked to find the distance between these two lines.

$p1 … x = 1 + t, y = -1 + 2t, z = t$

$p2 … x = 1 – t; y = 3 – t; z = t$

Those two lines are nonparallel and they do not intersect (I checked that).

Using the vector product I computed the normal (the line orthogonal to both of these lines), and the normal is $(3, -2, 1)$. Now I have the direction vector of the line which will intersect both of my nonparallel lines.

However, here's where I encounter the problem – I don't know what next. The next logical step in my opinion would be to find a point on $p1$ where I could draw that orthogonal line and where that orthogonal line would also intersect with $p2$… There's only one such point, since we are in 3D space and I could draw an orthogonal line from any point in $p1$ but it could miss $p2$.

Best Answer

Take the common normal direction.

$$\mathbf{n} = \pmatrix{1\\2\\1} \times \pmatrix{-1\\-1\\1} = \pmatrix{3 \\-2 \\1 } $$

Now project any point from the lines onto this direction. Their difference is the distance between the lines

$$ d = \frac{ \mathbf{n} \cdot ( \mathbf{r}_1 - \mathbf{r}_2 )}{\| \mathbf{n} \|} $$

$$ d = \frac{ \pmatrix{3\\-2\\1} \cdot \left( \pmatrix{1\\-1\\0} - \pmatrix{1\\2\\1} \right) }{ \| \pmatrix{3\\-2\\1} \|} = \frac{ \pmatrix{3\\-2\\1} \cdot \pmatrix{0\\-4\\0} } {\sqrt{14}} = \frac{8}{\sqrt{14}} = 2.1380899352993950$$

NOTE: The $\cdot$ is the vector inner product, and $\times$ is the cross product

Related Question