Distance between two skew lines in 3D space

I know this question exists but the answer is very vague, and I'm hoping someone could provide a more complete example (rather than just providing a formula that is difficult to use)

I have two lines:

1: $\begin{bmatrix} 1 \\ 0 \\ -1 \end{bmatrix} + t\begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix}$

2: $\begin{bmatrix} -1 \\ 1 \\ 0 \end{bmatrix} + s\begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix}$

How can I determine the shortest distance between them (without calculus, which I haven't learned yet)?

• "but that is an $f(s, t)$". What's that? Commented Nov 10, 2014 at 14:36

The shortest line joining line 1 and line 2 is perpendicular to each of them, so has direction $(1,2,3) \times (0,0,1) = (2,-1,0)$.

Make this a unit vector, $\mathbf{u} = (\frac{2}{\sqrt 5},-\frac{1}{\sqrt 5}, 0)$.

Take any point $\mathbf{p}_1$ on line 1, and any point $\mathbf{p}_2$ on line 2; in this case, the obvious choices are $\mathbf{p}_1 = (1,0,-1)$ and $\mathbf{p}_2 = (-1,1,0)$. Let $\mathbf{v} = \mathbf{p}_1-\mathbf{p}_2 = (2,-1,-1)$.

Now the distance between the lines is just $|\mathbf{u}.\mathbf{v}| = \sqrt 5$.

• But is that the shortest possible distance between them? How do you know its those two points? Commented Nov 10, 2014 at 14:56
• @Imray: Because $\mathbf{u}$ is perpendicular to both lines, the value of $|\mathbf{u.v}|$ is the same, whatever two points you choose as $\mathbf{p}_1$ and $\mathbf{p}_2$. Commented Nov 10, 2014 at 15:00
• I don't understand. If instead of $p_1 = (1, 0, -1)$ I used $p_1 = (6, 10, 14)$ - which is also a point on the line - I get a different length Commented Nov 10, 2014 at 15:15
• @Imray: "I get a different length": I don't! Please show your working. Commented Nov 10, 2014 at 15:22
• @Imray: Please show your working! Commented Nov 10, 2014 at 15:38

The shortest line joining them will have direction perpendicular to both lines so it will be in the direction of the cross product $(1,2,3)\times (0,0,1)$. The endpoints will be given by values $t=t_0$, and $s=s_0$. So you want to solve the equation $$(1,0,-1)+t(1,2,3)-\left((-1,1,0)+s(0,0,1)\right)=\lambda\left((1,2,3)\times (0,0,1)\right)$$ for $s,t$ and $\lambda$, and discard the value of $\lambda$. The values of $s$ and $t$ give you the endpoints, now plug those into the distance formula in $\mathbb{R}^3$.

• You don't need to solve for $s$ and $t$ $-$ see my answer. Commented Nov 10, 2014 at 14:57

The shortest distance between two skew lines lies along the line which is perpendicular to both the lines whose direction ratios can easily be obtained by the cross product of the direction ratios of the skew lines.If one is only interested in finding that distance than it is not necessary to find the specific points on the skew lines having the least distance between them.One can more easily get a plane containing one of the lines and being parallel to other line.And then can simply apply the distance formula for distance between a plane and a point since the plane and line were made parallel so distance from all the points from the plane would be equal. For finding the direction ratios of the plane do cross product of the direction ratios of the skew lines.Then use the point of any of the two lines and generate the plane. if skew lines were x=at+x1 , y=bt+y1 and z=ct+z1 and x=dt+x2 , y=et+y2 and z=ft+z2 than direction ratios = i(bf - ce) + j(cd - af ) + k(ae - bd) and then use one point (x1,y1,z1) or (x2,y2,z2) for generating the plane and other for calculating the distance from that plane.

• Please typeset your posts in MathJax to increase legibility. Commented May 14, 2020 at 21:14