4
$\begingroup$

I can find the shortest distance $d$ between two skew lines $\vec{V_1}$ and $\vec{V_2}$ in 3D space with $d=\left|\frac{(\vec{V_1}\times\vec{V_2})\cdot\vec{P_1P_2}}{|\vec{V_1}\times\vec{V_2}|}\right|$. But how do I calculate the actual points $A(x,y,z)$ and $B(x,y,z)$ on those two lines where said shortest distance $d$ is located? Thanks in advance.

$\endgroup$
2
  • $\begingroup$ What's $\vec{P_1P_2}$ ? $\endgroup$
    – user228113
    Aug 30, 2015 at 4:05
  • 1
    $\begingroup$ To tell the truth, I would be much more simple-minded about this problem than to use a formula like that. I would parametrize the two lines linearly, like $\ell_1: (kt+a, mt+b, nt+c)$, similarly for the other line, and (using different parameters $s$ and $t$), write out the square of the distance between the $s$-point on the first line and the $t$-point on the second. You get a quadratic expression in $s$ and $t$, which you can easily minimize. This gives you the values of $s$ (point on first line) and $t$ (point on second line). Easy as that. $\endgroup$
    – Lubin
    Aug 30, 2015 at 5:03

2 Answers 2

10
$\begingroup$

Here's a solution, which I have also added to Wikipedia (https://en.wikipedia.org/wiki/Skew_lines#Nearest_Points), done completely using vectors without a need to solve equations.

Expressing the two lines as vectors:

Line 1: $\mathbf{v_1}=\mathbf{p_1}+t_1\mathbf{d_1}$

Line 2: $\mathbf{v_2}=\mathbf{p_2}+t_2\mathbf{d_2}$

The cross product of $\mathbf{d_1}$ and $\mathbf{d_2}$ is perpendicular to the lines.

$\mathbf{n}= \mathbf{d_1} \times \mathbf{d_2}$

The plane formed by the translations of Line 2 along $\mathbf{n}$ contains the point $\mathbf{p_2}$ and is perpendicular to $\mathbf{n_2}= \mathbf{d_2} \times \mathbf{n}$.

Therefore, the intersecting point of Line 1 with the above mentioned plane, which is also the point on Line 1 that is nearest to Line 2 is given by

$\mathbf{c_1}=\mathbf{p_1}+ \frac{(\mathbf{p_2}-\mathbf{p_1})\cdot\mathbf{n_2}}{\mathbf{d_1}\cdot\mathbf{n_2}} \mathbf{d_1}$

Similarly, the point on Line 2 nearest to Line 1 is given by (where $\mathbf{n_1}= \mathbf{d_1} \times \mathbf{n}$)

$\mathbf{c_2}=\mathbf{p_2}+ \frac{(\mathbf{p_1}-\mathbf{p_2})\cdot\mathbf{n_1}}{\mathbf{d_2}\cdot\mathbf{n_1}} \mathbf{d_2}$

Now, $\mathbf{c_1}$ and $\mathbf{c_2}$ form the shortest line segment joining Line 1 and Line 2.

$\endgroup$
2
$\begingroup$

The minimum can be found with analytical method described by @Lubin in a comment. If you want to avoid explicit differentiation, you might take a shortcut: the shortest line segment between two lines is perpendicular to both lines.

Assuming $\vec A_0$ and $\vec B_0$ are points on each line, and their respective vectors are $\vec a$ and $\vec b$, so the point of one line is $$\vec A(t)=\vec A_0+t\vec a $$ and the point of the other one is $$\vec B(s)=\vec B_0+s\vec b$$

you have the segment $\overline{AB}$ must be perpendicular to $\vec a$ and to $\vec b$, which is equivalent to zero value of respective scalar products: $$\begin{cases} (\vec A(t)-\vec B(s))\cdot \vec a = 0 \\ (\vec A(t)-\vec B(s))\cdot \vec b = 0 \end{cases}$$ which results in a system of two linear equations with unknown $t,s$.

Solve it, plug $t$ and $s$ values into $\vec A(t)$ and $\vec B(s)$ definitions and you're done.

PS.
Don't forget to consider a special case of the two lines parallel.

EDIT

$$\begin{cases} (\vec A_0+t\vec a-\vec B_0-s\vec b)\cdot \vec a = 0 \\ (\vec A_0+t\vec a-\vec B_0-s\vec b)\cdot \vec b = 0 \end{cases}$$

$$\begin{cases} t(\vec a\cdot \vec a)-s(\vec a\cdot \vec b) = (\vec B_0-\vec A_0)\cdot \vec a \\ t(\vec a\cdot \vec b)-s(\vec b\cdot \vec b) = (\vec B_0-\vec A_0)\cdot \vec b \end{cases}$$

$\endgroup$
2
  • $\begingroup$ I guess I understand the principal idea, but I think I am missing something at the very end, i.e. $\begin{cases} (\vec A(t)-\vec B(s))\cdot \vec a = 0 \\ (\vec A(t)-\vec B(s))\cdot \vec b = 0 \end{cases}$. Could you please show me the two respective equations or steps to solve for $t$ and $s$? Is it $\vec A(t)-\vec B(s))\cdot \vec a = 0$? Thanks also for the reminder to consider two parallels, in that case any two points perpendicular to $\vec a$ and $\vec b$ would have the already calculated distance $d$. $\endgroup$
    – Dan A
    Oct 22, 2015 at 5:36
  • $\begingroup$ Couldn't finish editing my comment above. I wasn't aware of the 5 edit minute rule. Anyway, I am a bit confused on how to obtain the system of two linear equations. $\endgroup$
    – Dan A
    Oct 22, 2015 at 5:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .