Neha Patil (Editor)

Distance between two straight lines

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

The distance between two straight lines in the plane is the minimum distance between any two points lying on the lines. In case of intersecting lines, the distance between them is zero, because the minimum distance between them is zero (at the point of intersection); whereas in case of two parallel lines, it is the perpendicular distance from a point on one line to the other line.

Formula and proof

Because the lines are parallel, the perpendicular distance between them is a constant, so it does not matter which point is chosen to measure the distance. Given the equations of two non-vertical parallel lines

y = m x + b 1 y = m x + b 2 ,

the distance between the two lines is the distance between the two intercepts of these lines with the perpendicular line

y = x / m ,

This distance can be found by first solving the linear systems

{ y = m x + b 1 y = x / m ,

and

{ y = m x + b 2 y = x / m ,

to get the coordinates of the intercept points. The solutions to the linear systems are the points

( x 1 , y 1 )   = ( b 1 m m 2 + 1 , b 1 m 2 + 1 ) ,

and

( x 2 , y 2 )   = ( b 2 m m 2 + 1 , b 2 m 2 + 1 ) .

The distance between the points is

d = ( b 1 m b 2 m m 2 + 1 ) 2 + ( b 2 b 1 m 2 + 1 ) 2 ,

which reduces to

d = | b 2 b 1 | m 2 + 1 .

When the lines are given by

a x + b y + c 1 = 0 a x + b y + c 2 = 0 ,

the distance between them can be expressed as

d = | c 2 c 1 | a 2 + b 2 .

References

Distance between two straight lines Wikipedia