# [Math]Finding the shortest distance between two lines in 3D

Keywords: Math, shortest distance between two lines

The distance between two lines in \(\mathbb R^3\) is equal to the distance between parallel planes that contain these lines.

To find that distance first find the normal vector of those planes - it is the cross product of directional vectors of the given lines. For the normal vector of the form (A, B, C) equations representing the planes are:

\[ Ax + By + Cz + D_1 = 0 \]

\[ Ax + By + Cz + D_2 = 0 \]

Take coordinates of a point lying on the first line and solve for D1. Similarly for the second line and D2.

The distance we're looking for is:

\[ d = \frac{\lvert D_1 - D_2 \rvert}{\sqrt{A^2 + B^2 + C^2}} \]

Origin:

Finding the shortest distance between two lines

https://math.stackexchange.com/a/429434/601445

`Tell him yes. Even if you are dying of fear, even if you are sorry later, because whatever you do, you will be sorry all the rest of your life if you say no. ― Gabriel García Márquez, Love in the Time of Cholera`