# Shortest distance between two lines and find points on each line [duplicate]

I'm given the following two lines:

$$L_1$$: $$P_1=(−13, 3, 14)$$ with direction vector $$d_1=(2, −1, −2)$$

$$L_2$$: $$P_2=(5, 4, 4)$$ with direction vector $$d_2=(−2, 1, 0)$$

I'm then asked to find the shortest distance $$d$$ between these two lines, and then find a point, $$Q_1$$, on $$L_1$$, and a point, $$Q_2$$, on $$L_2$$ so that $$d(Q_1,Q_2) = d$$.

So far, I've determined that the shortest distance between these two points can be solved with a projection of the vector $$\vec{P_1P_2}$$ onto the direction vector found by the cross product of $$d_1$$ and $$d_2$$. In this case, it is $$(4,8,0)$$, or a magnitude of $$4\sqrt{5}$$.

I'm not really sure how to determine the two points now that I've gotten the distance, any tips or explanations would be appreciated.

• You can find many questions in the handy list of related questions at right that show you how to do this.
– amd
Sep 26, 2018 at 2:42
• @amd My searching skills have proven to not be what they once used to... Thanks! Sep 26, 2018 at 3:11
• No worries. For some reason the search function in the UI doesn’t work nearly as well as the one that finds related questions.
– amd
Sep 26, 2018 at 6:57

HINT

Let consider the plane orthogonal to a line and containing the other one.

Solve the subproblem ("what is the distance from a point to a line?" (you should have this in your notes or book)) then perform a constrained optimization problem by allowing that point to vary over the line.

If you parameterize both lines, then the square distance between two points, one on each line, is quadratic in the parameters. Do you know how to minimize a function of two variables?