Shortest distance

Given a point A and a line r=r0+tm\displaystyle \vec{r} = \vec{r}_{0} + t \vec{m}, we can find the shortest distance from the point to the line easily with

d=AB×mm\displaystyle d = \frac{\left \lvert \overrightharpoon{A B} \times \vec{m} \right \rvert}{\left \lvert \vec{m} \right \rvert}.

Given two parallel planes with a normal vector n\displaystyle \vec{n} (it doesn’t matter which plane you take it from) and containing points A and B, we can find the shortest distance between them using the scalar projection:

d=ABn=ABn^=ABnn\displaystyle d = \left \lvert \overrightharpoon{A B}_{n} \right \rvert = \left \lvert \overrightharpoon{A B} \cdot \hat{n} \right \rvert = \frac{\left \lvert \overrightharpoon{A B} \cdot \vec{n} \right \rvert}{\left \lvert \vec{n} \right \rvert}.

(Note that nonparallel planes intersect, so the shortest distance is zero.) We can also use this equation for skew lines, where one line contains A and the other has B. We calculate n\displaystyle \vec{n} by crossing their direction vectors:

n=m1×m2\displaystyle \vec{n} = \vec{m}_{1} \times \vec{m}_{2}.