What is the distance between the 3D lines $x = \begin{pmatrix} 1 \\ 2 \\ -4 \end{pmatrix} + \begin{pmatrix} -1 \\ 3 \\ -1 \end{pmatrix} t$ and $y = \begin{pmatrix} 0 \\ 3 \\ 5 \end{pmatrix} + \begin{pmatrix} 1 \\ 4 \\ 3 \end{pmatrix} u.$

Hint: To find the distance, try to calculate $AB$'s smallest possible value, where $A$ represents a point which lies on one line and $B$ represents a point which lies on the other line.

I remember a handy formula here: http://math.harvard.edu/~ytzeng/worksheet/distance.pdf that allows mathematicians to find the distance between 3D lines, but I would rather solve the problem given the method that was hinted.

I'm not entirely sure how to solve it this way, however. Would I try to find a value for both $t$ and $u$ that makes lines $x$ and $y$ the smallest value? I don't know if I'm thinking of solving this problem correctly.



2 Answers 2


Yes, to derive this, the natural approach would be to consider the function $$ F(t,u) = |x(t)-y(u)| $$ If you plug the definition of $x(t)$ and $y(u)$ into the distance formula and simplify a bit, you get $F(t,u) = \sqrt{P(t,u)}$ where $P$ is some quadratic polynomial in two variables. The minimum of $F$ occurs at the same $(t,u)$ as the minimum of $P$, which should be easy to find using calculus. Then plug the $(t,u)$ you find back into the expression you got for $F$.

  • $\begingroup$ @HemmingMakholm: Thanks. I have not taken calculus yet however--is there another way? $\endgroup$
    – Grace
    Commented Jul 23, 2015 at 23:32
  • $\begingroup$ Would I get: $\frac{82\sqrt{10}}{15}$? $\endgroup$
    – Grace
    Commented Jul 24, 2015 at 0:03
  • $\begingroup$ @Grace: The hint you quote does seem to point towards calculus. You can probably also get through without it by saying that $(t,u)$ must be such that $t$ gives the minimum of $P(t,u)$ for among all other possible $t$ for that particular $u$, and $u$ must give the minimum of $P(t,u)$ among all other possible $u$ for that $t$. Each of these halves can be tackled by just knowing how to find the minimum of a one-variable quadratic, and you would then get two linear equations in $t$ and $u$ that you can solve -- namely the same equations that calculus would give you. $\endgroup$ Commented Jul 24, 2015 at 0:08
  • $\begingroup$ @Grace: Perhaps -- I'm lazy and haven't actually done the calculations myself. :-) $\endgroup$ Commented Jul 24, 2015 at 0:09
  • $\begingroup$ Alternatively, if you know sufficiently much vector algebra, you can look for the normal distance between the two parallel planes that contain the two lines. The common normal for these two planes could be found as the cross product $(-1,3,-1)\times(1,4,3)$. $\endgroup$ Commented Jul 24, 2015 at 0:11

If you have access to a computational 3D geometry system, here is a fairly straightforward solution. Let's call the two skew lines L1 and L2.

  1. Start by visualizing the closest-approach "bridge" Line Segment BR. The run direction of BR (as a unit vector) can be obtained by computing the normalized cross-product of the L1 and L2's run directions:

    BR_dir =  normalize( L1_dir x L2_dir)

2a. Extrude L1 into a plane PL1 in the extrusion direction BR_dir.

2b. Extrude L2 into a plane PL2 in the extrusion direction BR_dir.

  1. The bridging line segment's endpoints are intersections of plane + line:

    BR_endPt1 = intersection (L1, PL2)

    BR_endPt2 = intersection (L2, PL1)

  2. The distance between L1 and L2 at closest approach is the length of BR, easily computed from its endpoints.

This same algorithm (bridging line segment of two skew lines) can also serve to find the intersection of two coplanar lines in 3D. In that case, the bridging line segment consists of two identical points, which solve for the intersection of the two lines.

Because of finite precision in algorithmic geometry, it is actually very hard to create two exactly coplanar lines (even when they share a common point). Because of numerical error, they effectively become skew lines that approach very closely. For that reason, the bridging line segment algorithm is more practical than one that assumes coplanar lines meet up perfectly (which would require infinite precision real numbers in the representations).


You must log in to answer this question.

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