Given the following parametric find the distance between the two lines:
$x=2+t\;,\;\; y=1+6t\;,\;\; z=2t$ and
$x=1+2s\;,\;\; y=6+14s\;,\;\; z=-1+5s$
I tried using a point on the first line called P and entered $s=0$ and $s=2$ to get q and r. I then took the cross product of qr and qp then used the distance formula but this didn't seem to work.
$\endgroup$ 12 Answers
$\begingroup$The squared distance between a point on each line is given by
$$d_{ts}^2=(1+t-2s)^2+(-5+6t-14s)^2+(1+2t-5s)^2.$$
Now you need to find the shortest distance and it suffices to cancel the partial derivaties on $t$ and $s$:
$$\begin{cases} 2(1+t-2s)+12(-5+6t-14s)+4(1+2t-5s)=0\\ -4(1+t-2s)-28(-5+6t-14s)-10(1+2t-5s)=0.\\ \end{cases}$$
By solving the linear system, you get $t$ and $s$, then the points and the distance.
$\endgroup$ 2 $\begingroup$You can write a point on the first line as $P = (2,1,0) + t(1,6,2)$ and a point on the second line as $Q = (1,6,-1) + s(2,14,5)$. If you take the difference $P - Q$ you get $(1,-5,1) + t(1,6,2) + s(-2,-14,-5)$.
So your problem is equivalent to finding the distance between the plane given by $(1,-5,1) + t(1,6,2) + s(-2,-14,-5)$ and the origin. The first step here is to find a normal vector $\mathbf{n}$ to the plane, you can use $\mathbf{n} = (1,6,2) \times (-2,-14,-5) = (-2,1,-2)$. Now take any vector $\mathbf{v}$ in the plane (for example, $\mathbf{v} = (1,-5,1))$ you can compute the distance as:
$$D = \frac{|\mathbf{v} \cdot \mathbf{n}|}{||\mathbf{n}||} = \frac{|-2 - 5 - 2|}{\sqrt{4 + 1 + 4}} = \frac{9}{3} = 3$$
In general, if your lines are given by $\mathbf{p} + t\mathbf{v}$ and $\mathbf{q} + s\mathbf{w}$, you can compute:
$$D = \frac{|(\mathbf{p} - \mathbf{q}) \cdot \mathbf{n}|}{||\mathbf{n}||}; \qquad \qquad \mathbf{n} = \mathbf{v} \times \mathbf{w}$$
$\endgroup$