distance from point to a line


The distanceMathworldPlanetmath from a point P with coordinates (xp,yp)2 to the line with equation ax+by+c=0 is given by |axp+byp+c|/a2+b2.

Proof Every point x,y on the line is at some distance (x-xp)2+(y-yp)2 from P. What we need to find is the minimum such distance. Our problem is

min(x-xp)2+(y-yp)2

subject to

ax+by+c=0

This problem is solvable using the Lagrange multiplier method. We minimize

(x-xp)2+(y-yp)2+λ(ax+by+c)

Calculating the derivatives with respect to x,y and λ and setting them to zero we get three equations:

2x-2xp+λa=0 (1)
2y-2yp+λb=0 (2)
2ax+2by+2c=0 (3)

Solving these leads to xp-x=aaxp+byp+ca2+b2 and yp-y=baxp+byp+ca2+b2. We can now substitute these expressions into (x-xp)2+(y-yp)2 and we get (after some simplification) the desired result.

Title distance from point to a line
Canonical name DistanceFromPointToALine
Date of creation 2013-03-22 15:24:30
Last modified on 2013-03-22 15:24:30
Owner acastaldo (8031)
Last modified by acastaldo (8031)
Numerical id 7
Author acastaldo (8031)
Entry type Result
Classification msc 51N20
Related topic DistanceOfNonParallelLines
Related topic DistanceBetweenTwoLinesInR3
Related topic Envelope
Related topic AngleBisectorAsLocus