Navigation   Home   Search   Site map

# document.write (document.title)

 Contact Graeme   Home   Email   Twitter
 Math Help > Geometry > Points and Lines > Distance from line to point

### What is the distance from a given line to a given point?

Given a line of the form Ax+By+C=0 and a point (h,k), the perpendicular distance from the line to the point is

|Ah+Bk+C|/sqrt(A2+B2)

### Proof

Consider all the lines perpendicular to Ax+By+C=0.  They have the form Bx-Ay+D=0, where A and B are fixed, and D varies to select one of the infinitely many perpendicular lines.  To select the line that goes through (h,k), just select D=-(Bh-Ak), so the equation of the line perpendicular to

Ax+By+C=0

that passes through (h,k) is

Bx-Ay-(Bh-Ak)=0

Solving the two lines to find their point of intersection gives us

x = (B2h-ABk-AC)/(A2+B2)

and

y = (A2k-ABh-BC)/(A2+B2)

Now, the distance from this point of intersection (x,y) to (h,k) is

sqrt((x-h)2+(y-k)2), and then plugging in x and y gives us
sqrt(((B2h-ABk-AC)/(A2+B2)-h)2+((A2k-ABh-BC)/(A2+B2)-k)2),

which, amazingly, simplifies to

sqrt((Ah+Bk+C)2/(A2+B2))

so the final solution is

|Ah+Bk+C|/sqrt(A2+B2)

### Related pages in this website

Lines in 3 dimensions: Equation of a line in three dimensions, the distance between two lines, finding the closest points of the two lines.

The distance from Ax+By+C=0 to a point is used in Tangents to 2 Circles.

An aside in Point and Triangle2 gives the distance dAB from (x,y) to line AB where A=(x1,y1), B=(x2,y2)

Vectors, and their dot product, cross product.

The webmaster and author of this Math Help site is Graeme McRae.