Shortest distance between two lines in 3-dimensional space

3k Views Asked by At

Can someone explain to me how to solve this question?

Find the shortest distance between the lines $L_1 = \left\{t \begin{bmatrix} 1\\ 1\\ 1\end{bmatrix} : t \in \mathbb{R}\right\}$ and $L_2 = \left\{s \begin{bmatrix} 1\\ 2\\ 3\end{bmatrix} + \begin{bmatrix} 1\\ 0\\ 0\end{bmatrix}: s \in \mathbb{R}\right\}$

Thanks

3

There are 3 best solutions below

0
On BEST ANSWER

First take the cross product of the two direction vectors: $<1,1,1>\times<1,2,3>=<1,-2,1>$. We can normalize to the unit vector $\frac{1}{\sqrt6}<1,-2,1>$
The minimum distance will be the length of the scalar projection of any line segment joining L1 and L2 onto this unit vector. We have the points (0,0,0) on L1 and (1,0,0) on L2, which are joined by the vector <1-0,0-0,0-0>=<1,0,0>. The length of the scalar projection will then be the magnitude of the dot product of <1,0,0> and $\frac{1}{\sqrt6}<1,-2,1>$, which is $\frac{1}{\sqrt6}$

0
On

The difference vector is $$ d = L_2(s) - L_1(t) = s (1,2,3) + (1,0,0) - t (1,1,1) = (s - t + 1, 2s - t, 3s - t) $$ Then $$ q = \lVert d \rVert^2 = d^2 = (s-t+1)^2 + (2s - t)^2 + (3s - t)^2 $$ Then the gradient is $$ q_s =2(s-t+1)+ 4 (2s-t) + 6(3s-t) = 28s-12t + 2 \\ q_t = -2(s-t+1)-2(2s-t) -2(3s-t) = -12s+6t-2 $$ It vanishes for $$ \left( \begin{array}{rr|r} 28 & -12 & -2 \\ -12 & 6 & 2 \end{array} \right) \to \left( \begin{array}{rr|r} 16 & -6 & 0 \\ -12 & 6 & 2 \end{array} \right) \to \left( \begin{array}{rr|r} 16 & -6 & 0 \\ 4 & 0 & 2 \end{array} \right) \to \\ \left( \begin{array}{rr|r} 16 & -6 & 0 \\ 1 & 0 & 1/2 \end{array} \right) \to \left( \begin{array}{rr|r} 0 & -6 & -8 \\ 1 & 0 & 1/2 \end{array} \right) \to \left( \begin{array}{rr|r} 1 & 0 & 1/2 \\ 0 & 1 & 4/3 \end{array} \right) $$ So $s = 1/2$ und $t = 4/3$. This gives $q = d^2 = (1/6)^2 + (-1/3)^2 + (1/6)^2 = 1/18 + 1/9 = 3/18 = 1/6$ and $d = 1/\sqrt{6}$.

visual (Large version)

0
On

The Euclidean distance between the two lines is

$$\left\|s \begin{bmatrix} 1\\ 2\\ 3\end{bmatrix} - t \begin{bmatrix} 1\\ 1\\ 1\end{bmatrix} + \begin{bmatrix} 1\\ 0\\ 0\end{bmatrix}\right\| = \left\|\begin{bmatrix} 1 & -1\\ 2 & -1\\ 3 & -1\end{bmatrix} \begin{bmatrix} s\\ t\end{bmatrix} - \begin{bmatrix} -1\\ 0\\ 0\end{bmatrix}\right\|$$

Minimizing this Euclidean distance is a least-squares problem. The mininimizer of $\| A x - b\|$ is given by the solution to the so-called normal equations $A^T A x = A^T b$. Since

$$\begin{bmatrix} 1 & -1\\ 2 & -1\\ 3 & -1\end{bmatrix}^T \begin{bmatrix} 1 & -1\\ 2 & -1\\ 3 & -1\end{bmatrix} = \begin{bmatrix} 14 & -6\\ -6 & 3\end{bmatrix}, \qquad{} \begin{bmatrix} 1 & -1\\ 2 & -1\\ 3 & -1\end{bmatrix}^T \begin{bmatrix} -1\\ 0\\ 0\end{bmatrix} = \begin{bmatrix} -1\\ 1\end{bmatrix}$$

the normal equations give us the following system of equations

$$\begin{bmatrix} 14 & -6\\ -6 & 3\end{bmatrix} \begin{bmatrix} s\\ t\end{bmatrix} = \begin{bmatrix} -1\\ 1\end{bmatrix}$$

whose solution is $\begin{bmatrix} s\\ t\end{bmatrix} = \begin{bmatrix} \frac{1}{2}\\ \frac{4}{3}\end{bmatrix}$. The minimum Euclidean distance between the two lines is, thus,

$$\left\|\frac{1}{2} \begin{bmatrix} 1\\ 2\\ 3\end{bmatrix} - \frac{4}{3} \begin{bmatrix} 1\\ 1\\ 1\end{bmatrix} + \begin{bmatrix} 1\\ 0\\ 0\end{bmatrix}\right\| = \left\|\begin{bmatrix} \frac{1}{6}\\ -\frac{1}{3}\\ \frac{1}{6}\end{bmatrix}\right\| = \frac{1}{\sqrt{6}}$$