Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Say we're interested in the distance between the diagonals $u=(0,0,0)+(1,0,1)t$ and $v=(0,0,1)+(1,1,0)s$ of a unit cube.

The standard formula for the distance between two skew lines $$d=|\mathbf n\cdot (\mathbf a - \mathbf b) |$$ gives $\frac{1}{\sqrt{3}}$. That's likely the answer I am seeking. But, since my original, intuitve approach conflicts with this, I don't want to give up on it.

I considered the distance from the center of a face to the center of an adjacent face. That distance is $\frac{\sqrt{2}}{2}$. The distance from a cube vertex to the center of an "adjacent" face is also $\frac{\sqrt{2}}{2}$ (for example, from $(1,0,1)$ to $(\frac{1}{2},0,1)$ or from $(0,0,1)$ to $(\frac{1}{2},0,\frac{1}{2})$). Since the distance between the two lines is unique, I know then that the distance I want is less than that.

Where is that unique segment, perpedicular to both diagonals?

share|improve this question
@Heitor Yikes! Thanks for catching that. But my question still stands as to how to approach the problem geometrically. –  sasha Mar 27 '13 at 10:55
Why do you think the minimal line would be perpendicular to both diagonals? –  Eckhard Mar 27 '13 at 10:57
@Eckhard Isn't that a fact? The normal is perpendicular to both. –  sasha Mar 27 '13 at 11:02
I think it isn't. In this particular case it makes a 45 degree angle with either diagonal. The minimal line between a point and a line is perpendicular to that line. –  Eckhard Mar 27 '13 at 11:07
@Eckhard Are you saying that the distance between two skew lines is not the same as th length of the common perpendicular? Isn't the cross-product used in the formula for $d$ for this reason? –  sasha Mar 27 '13 at 11:18

3 Answers 3

up vote 3 down vote accepted

Edited to get the picture right.

I don't have much to add to André Nicolas' answer, except a picture I quickly drew with Mathematica.

enter image description here

With a little imagination one can see that the minimal line indeed makes right angles with either diagonal.

The Mathematica code used to generate the picture is

s = 2/3; t = 1/3;

Graphics3D[{Line[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 0}}],
  Line[{{0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}, {0, 0, 1}}],
  Line[{{0, 0, 0}, {0, 0, 1}}],
  Line[{{0, 1, 0}, {0, 1, 1}}],
  Line[{{1, 1, 0}, {1, 1, 1}}],
  Line[{{1, 0, 0}, {1, 0, 1}}],
  {Red, Line[{{0, 0, 0}, {1, 0, 1}}],
  Line[{{0, 0, 1}, {1, 1, 1}}]},
  {Blue, PointSize[Large], Point[{s, 0, s}], Point[{t, t, 1}], 
   Line[{{s, 0, s}, {t, t, 1}}]}
  }, Boxed -> False]
share|improve this answer
wow! Would you mind sharing your code? I'd be grateful. –  sasha Mar 27 '13 at 11:19
What's was your reasoning process? My imagination tells me that there's another segment congruent to your blue one. So that can't be the answer. Edit: after your edit...I think it's starting to make sense. –  sasha Mar 27 '13 at 11:21
Where would that putative congruent line segment be? –  Eckhard Mar 27 '13 at 11:27
I'm accepting this answer because it helped me "see" the solution. Like I said before, I could do the calculation using a cross and dot product--no trouble there; troublesome was seeing where it was located relative to the cube. Thank you! –  sasha Mar 29 '13 at 6:14

We want to choose $s$ and $t$ so that the distance from $(s,s,1)$ to $(t,0,t)$ is minimized. The square of the distance is $$(s-t)^2+s^2+(1-t)^2,$$ which simplifies to $2s^2+2t^2 -2st -2t+1$. To minimize, set the partial derivatives equal to $0$. We get $4s-2t=0$, $4t-2s-2=0$.

When we solve the system of two equations, we get $s=1/3$, $t=2/3$. This identifies the points of nearest approach on each line.

If we substitute in the expression for square of distance, we find that the minimum distance is indeed $\dfrac{1}{\sqrt{3}}$.

There is undoubtedly a much nicer geometric approach.

share|improve this answer
Sweet! But I got the same answer using a cross product and a dot product! I'm looking for a geometric approach now. –  sasha Mar 27 '13 at 11:23

A geometric approach: we only use the concept of orthogonality.

The two diagonals lie respectively on the lines $\ell_1,\ell_2$ which we write as affine spaces as $$\ell_1=\langle u_1\rangle, \quad \ell_2= \begin{pmatrix} 0\\ 0\\ 1 \end{pmatrix}+\langle u_2\rangle $$ where $u_1=(1, 0, 1)$ and $u_2=(1,1,0)$. Now let $v$ be the generic vector connecting the two lines, $$v=P_s-P_t=\begin{pmatrix} s-t\\ s\\ 1-t \end{pmatrix}$$ Imposing perpendicularity $v\perp u_1$ and $v\perp u_2$ we get: $$(v,u_1)=s-2t+1=0 \\ (v,u_2)=2s-t=0$$ The solution of this linear system is $s=1/3$ and $t=2/3$. By substituting this in $v$ we get the direction vector of the line $r$ on which lies our segment. More conveniently let $u=3v=(-1, 1, 1)$, which represents the same direction. What remains to be found is a point $P=(x_0, y_0, z_0)\in r$ so that we can write

$$r= P+\langle u \rangle=\begin{pmatrix} x_0-t\\ y_0+t\\ z_0+t \end{pmatrix} $$ By imposing the intersections of $r$ with $\ell_1$ and $\ell_2$ you can explicit out $x_0,y_0,z_0$.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.