Colorful House of Math logo
Log in

How to Find the Distance Between Two Lines

Two non-intersecting lines inside a three-dimentional coordinate system

As long as two lines don’t intersect, there will be one point on each line where the two lines are closest to each other. To find the distance between two lines at this point, you use the directional vectors of both lines to find another vector that is perpendicular to both lines. If you have a line l along the vector rl and another line k along the vector rk, this is how you find the shortest distance between the lines:

Rule

The Distance Between Two Lines

1.
Let P be a random point on the line l and Q be a random point on the line k. Express these points by using the parametric equations of the lines.
2.
Create an expression for the vector PQ.
3.
At the point where the two lines are closest to each other, the vector PQ is perpendicular to both lines. This means that you want
PQ rl PQ rl = 0

and

PQ rk PQ rk = 0.
4.
You now have two equations with two unknowns, and you have a system of equations to solve.
5.
When you find values for both s and t, you can insert those into the expression for PQ to find what that vector looks like at the point where the two lines are closest to each other.
6.
Finally, you can find |PQ|, which will be the distance between the lines.

Example 1

Find the distance between the lines

l: x (t) = 1 + t, y (t) = 2t, z (t) = 1 + 3t

l: x (t) = 1 + t,y (t) = 2t,z (t) = 1 + 3t

and
k: x (t) = 2 + s, y (t) = 1 + s, z (t) = 1 + s

k: x (s) = 2 + s,y (s) = 1 + s,z (s) = 1 + s

1.
To begin with, you make a point P by using the parametric equation of l and a point Q by using the parametric equation of k:
P = (1 + t, 2t, 1 + 3t)

and

Q = (2 + s,1 + s, 1 + s).
2.
Create PQ:
PQ = (2 + s (1 + t),1 + s (2t), 1 + s (1 + 3t) ) = (1 + s t,1 + s 2t,s 3t).

PQ = (2 + s (1 + t),1 + s (2t), 1 + s (1 + 3t)) = (1 + s t,1 + s 2t,s 3t).

3.
Find
PQ rl PQ rl = 0

and

PQ rk PQ rk = 0.

The vector rl is made up of the numbers in front of t in the parametric equation of l, and the vector rk is made up of the numbers in front of s in the parametric equation of k. That gives you

(1 + s t,1 + s 2t,s 3t) (1, 2, 3) = 0 1 + s t 2 + 2s 4t + 3s 9t = 0 1 + 6s 14t = 0 (1 + s t,1 + s 2t,s 3t) (1, 1, 1) = 0 1 + s t 1 + s 2t + s 3t = 0 3s 6t = 0

(1 + s t,1 + s 2t,s 3t) (1, 2, 3) = 0 1 + s t 2 + 2s 4t + 3s 9t = 0 1 + 6s 14t = 0 (1 + s t,1 + s 2t,s 3t) (1, 1, 1) = 0 1 + s t 1 + s 2t + s 3t = 0 3s 6t = 0

4.
Solve the system of equations:
3s 6t = 0 3s = 6t s = 2t 1 + 6s 14t = 0 1 + 6 2t 14t = 0 1 2t = 0 t = 1 2 s = 2t s = 1

1 + 6s 14t = 0 3s 6t = 0 3s = 6t s = 2t 1 + 6 2t 14t = 0 1 2t = 0 t = 1 2 s = 2 ( 1 2 ) s = 1

5.
Put the values you found for s and t back into the expression for PQ :
PQ = (1 + (1) ( 1 2 ) , 1 + (1) 2 ( 1 2 ) , (1) 3 ( 1 2 ) ) = (1 2,1, 1 2) .

PQ = (1 + (1) ( 1 2 ) ,1 + (1) 2 ( 1 2 ) , (1) 3 ( 1 2 )) = (1 2,1, 1 2) .

6.
Then you can finally find the length of PQ, which is the distance between the two lines: |PQ| = (1 2) 2 + 12 + (1 2) 2 = 1 4 + 1 + 1 4 = 3 2

Want to know more?Sign UpIt's free!
White arrow pointing to the LeftPrevious entry
How to Find the Distance from a Point to a Line
Next entryWhite arrow pointing to the right
How to Find the Distance Between a Point and a Plane