distance from point to a line


The distanceMathworldPlanetmath from a point P with coordinates (xp,yp)∈ℝ2 to the line with equation a⁢x+b⁢y+c=0 is given by |a⁢xp+b⁢yp+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

a⁢x+b⁢y+c=0

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

(x-xp)2+(y-yp)2+λ⁢(a⁢x+b⁢y+c)

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

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

Solving these leads to xp-x=a⁢a⁢xp+b⁢yp+ca2+b2 and yp-y=b⁢a⁢xp+b⁢yp+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