Finding the points on two lines where the minimum distance is achieved

linear algebravectors

Given two lines:

$$r_1(t) = (a_1, b_1, c_1) + t(p_1, q_1, r_1)$$

$$r_2(s) = (a_2, b_2, c_2) + s(p_2, q_2, r_2)$$

I have calculated the cross product of the direction vectors to get the vector perpendicular to both lines:

$$\vec n = (p_1, q_1, r_1) \times (p_2, q_2, r_2)$$

Which gives the vector $\vec n$.

I then got a vector $\vec V$ between a point on each line, and calculated the minimum distance $d$ between both lines by finding the scalar projection of $\vec V$ onto $\vec n$.

$$d = \frac{|\vec V \cdot \vec n|}{|\vec n|}$$

I now need the points on both lines where this minimum distance is achieved, how would I go about doing that?

Thanks for any help.

Best Answer

$L_1(t) = (a_1, b_1, c_1) + t(p_1, q_1, r_1)$

$L_2(s) = (a_2, b_2, c_2) + s(p_2, q_2, r_2)$

If two points on lines $L_1$ and $L_2$ are $A$ and $B$ resp.,

$\vec {AB} = (a_1-a_2+tp_1-sp_2, \, b_1-b_2+tq_1-sq_2, \, c_1-c_2+tr_1-sr_2)$

to find two points on lines with minimal distance, the vector $\vec {AB}$ should be perpendicular to both lines. So the dot product of $\vec {AB}$ to the directional vectors of both lines be zero.

$\vec {AB}\cdot(p_1,q_1,r_1) = 0$

$\vec {AB}\cdot(p_2,q_2,r_r) = 0$

Solve for $s$ and $t$ and that should give you two points. You can also find the minimum distance from there.

Related Question