# Thread: shortest distance between two lines

1. ## shortest distance between two lines

Hi,

I have to find the shortest distance between the two lines
$\displaystyle l_{1} (x,y,z) = (1,1,1) -t(6,3,2)$

and
$\displaystyle l_{2} ~~ x+y=y+z=\frac{x+z}{2}$

I know that i need two points, one each line $\displaystyle p_{1}\in l_{1}, ~ p_{2} \in l_{2}$

So if i pick the points $\displaystyle p_{1} = (-5,-2,-1), p_{2} = (0,0,0)$

What's the next step?

2. Originally Posted by Jones
Hi,

I have to find the shortest distance between the two lines
$\displaystyle l_{1} (x,y,z) = (1,1,1) -t(6,3,2)$

and
$\displaystyle l_{2} ~~ x+y=y+z=\frac{x+z}{2}$

I know that i need two points, one each line $\displaystyle p_{1}\in l_{1}, ~ p_{2} \in l_{2}$

So if i pick the points $\displaystyle p_{1} = (-5,-2,-1), p_{2} = (0,0,0)$

What's the next step?
The shortest distance between two lines is the perpendicular distance between the points of closest approach. Does this help?

-Dan

3. I know you can use the Pythagorean theorem to calculate the distance. I just have to find the sides of the triangle.

How do i find the projection of $\displaystyle \vec{p_{1}p_{2}} = (5,2,1)$ on the normal to $\displaystyle p_{1}$ plane?.

4. Okay, I'm going to derail you and if you wish to seek help from somewhere else go ahead. I had to look this up and I don't recognize your method. (If it is a version of your method I am not seeing the geometry.)

The pay-off for this method is at the end of this (lengthy) post.

First we need to convert your line equations to a different format. I am going to define the vector
$\displaystyle \vec{M} = a \hat{i} + b \hat{j} + c \hat{k}$

to be a vector parallel to the line. We have a vector
$\displaystyle \vec{R} = x \hat{i} + y \hat{j} + z \hat{k}$

which is the position vector from the origin to a general point on the line (x, y, z). Finally we have a vector
$\displaystyle \vec{R_0} = x_0 \hat{i} + y_0 \hat{j} + z_0 \hat{k}$

which is the position vector from the origin to a specific point on the line (x0, y0, z0).

The equation of the line is
$\displaystyle \vec{M} \times ( \vec{R} - \vec{R_0} ) = 0$

As an example of this, let's look at your first line: (x, y, z) = (1 - 6t, 1 - 3t, 1 - 2t) and the point on the line (x0, y0, z0) = (-5, -2, -1). R0 is easy enough:
$\displaystyle R_0 = -5 \hat{i} -2 \hat{j} - \hat{k}$

So we need M.

Eliminate t from the line equations to give
$\displaystyle x = -2 + 3z$

$\displaystyle y = -\frac{1}{2} + \frac{3}{2}z$

$\displaystyle z = z$

It is also known that a, b, and c are related by
$\displaystyle \frac{x - x_0}{a} = \frac{y - y_0}{b} = \frac{z - z_0}{c}$

and use P0:
$\displaystyle \frac{x + 5}{a} = \frac{y + 2}{b} = \frac{z + 1}{c}$

Now put in your values of x and y in terms of z:
$\displaystyle \frac{3 + 3z}{a} = \frac{\frac{3}{2} + \frac{3}{2}z}{b} = \frac{z +1}{c}$

If we choose b = 1/2 that gives us a = 1. c can be found by noting that no value of c will let 3 + 3z = z + 1. So we let c = 0. (This apparent contradiction stems from the derivation of the (x - x0)/a = (y - y0)/b = (z - z0)/c equation.)

So we finally know that
$\displaystyle \vec{M} = \hat{i} + \frac{1}{2} \hat{j}$

(whew!) Take a breather.

I'll leave it to you to find the equation of your other line. Let's call it
$\displaystyle \vec{M_1} \times ( \vec{R} - \vec{R_1} ) = 0$

Then the distance between the two lines is
$\displaystyle d = \frac{| \vec{M_1} \times \vec{M_0} \cdot ( \vec{R_1} - \vec{R_0} ) |}{| \vec{M_0} \times \vec{M_1} |}$

(Perhaps one of the other members will have a faster method for you!)

-Dan