I have two lines that are moving in some velocity in 3d. What would be a proper way to calculate the shortest distance between them?
How to calculate the shortest distance between two lines moving in 3d?
0
$\begingroup$
linear-algebra
-
1Do you mean the shortest distance between two lines or do you mean the shortest distance between two particles moving on straight lines? – 2017-02-24
-
0between two lines – 2017-02-25
-
0OK well you have the correct answer from @Kenny Wong below – 2017-02-25
1 Answers
3
There is a nice trick for doing this. Suppose the lines pass through $\vec{a_1}, \vec{a_2}$ respectively and have direction vectors $\vec{d_1}, \vec{d_2}$ respectively. Then the vector $\vec{n} = (\vec{d_1} \times \vec{d_2})/(|\vec{d_1} \times \vec{d_2}|)$ is orthogonal to both lines. To get the shortest distance between the lines, just project $(\vec{a_2} - \vec{a_1})$ in the direction of $\vec{n}$, i.e. your answer is $(\vec{a_2} - \vec{a_1}).\vec{n}$.