The point-line distance in two dimensions is the shortest distance from a point to a line. The equation of a line in slope-intercept form is given by
|
(1)
|
so the line has slope . Now consider the distance from a point
to the line. Points on the line have the vector
coordinates
|
(2)
|
Therefore, the vector
|
(3)
|
is parallel to the line, and the vector
|
(4)
|
is perpendicular to it. Now, a vector from the point to the line is given by
|
(5)
|
Projecting onto
,
|
(6)
| |||
|
(7)
| |||
|
(8)
| |||
|
(9)
| |||
|
(10)
| |||
|
(11)
|
If the normal vector points to the positive side of the line,
dropping the absolute value in the last expression
gives the signed distance.
If the line is specified by two points and
,
then a vector perpendicular
to the line is given by
|
(12)
|
Let
be a vector from the point
to the first point on the line
|
(13)
|
then the distance from to the line is again given by projecting
onto
,
giving
|
(14)
|
As it must, this formula corresponds to the distance in the three-dimensional case
|
(15)
|
with all vectors having zero -components, and can be written in the slightly more concise
form
|
(16)
|
where
denotes a determinant.
The distance between a point with exact trilinear coordinates and a line
is
|
(17)
|
(Kimberling 1998, p. 31).