Shortest Distance between a Point and a Line
Suppose the equation of a line is given by Ax + By + C = 0 and a point is given by the rectangular coordinates P(x0, y0). Then the perpendicular distance, i.e. the shortest distance, between the point and the line is given by the formula:
\[d = \dfrac{|Ax_0+By_0+C|}{\sqrt{A^2+B^2}}\]
In Figure 1, a right triangle is created at point P such that the legs are either perpendicular or parallel to the coordinate axes. The segment of length d is also drawn from P perpendicular to the line. The segments of length Δy and Δx intersect the line creating a segment of length AB shown in Figure 1. The ratio Δy/Δx represents the slope, m, of the line, which can also be represented as –(A/B).
From the givens in the figure, we know that the area, K, of the larger right triangle APC is \(K = \dfrac{1}{2}\Delta x \Delta y\). The area of this triangle is also given by \(K = \dfrac{1}{2}\overline{\text{AB}}d\) since AB is the base and d is the altitude of the same triangle. Therefore:
(i) \(\overline{\text{AB}}d = \Delta x \Delta y\) or \(d = \dfrac{\Delta x \Delta y}{\overline{\text{AB}}}\)
The length of segment AB is also given by \(\overline{\text{AB}} = \sqrt{(\Delta x)^2 + (\Delta y)^2}\), we have
(ii) \(d = \dfrac{\Delta x \Delta y}{\sqrt{(\Delta x)^2 + (\Delta y)^2}} = \dfrac{\Delta x \Delta y}{\Delta x\sqrt{1+\left(\dfrac{\Delta y}{\Delta x} \right)^2}} = \dfrac{\Delta y}{\sqrt{1+m^2}}\), where m is the slope of the line.
The slope of the line is also given by \(m = -\dfrac{A}{B}\). We need only to express Δy in terms of the coordinates of P and the coefficients of the line. In the figure, Δy is the vertical distance from the intersection of the line to the point P. The intersection of the line and the segment occurs at x0. We can substitute x0 in the equation of the line to find the y coordinate of the intersection. Thus, Δy, which is always a positive distance, is given by:
(iii) \(\Delta y = \left|\dfrac{-C-Ax_0}{B}-y_0\right| = \left|\dfrac{-C-Ax_0-By_0}{B}\right|\).
Equation (iii) can be written as:
(iv) \(\Delta y = \left|\dfrac{Ax_0+By_0+C}{B}\right|\).
After substituting (iv) in (ii), then the distance is now given by:
(v) \(d = \dfrac{|Ax_0+By_0+C|}{|B|\sqrt{1+\left(\dfrac{A}{B}\right)^2}} = \dfrac{|Ax_0+By_0+C|}{\sqrt{A^2+B^2}}\)
If we write the equation of the line Ax + By + C = 0 as –mx + y – b = 0 and scale the y term so that its coefficient equals 1, then B would equal 1. Therefore, the equation in (ii) can be written as \(\dfrac{|mx_0-y_0+b|}{\sqrt{1+m^2}}\).
The shortest distance between a point and a line, Ax + By + C = 0, is given by: \(d = \dfrac{|Ax_0+By_0+C|}{\sqrt{A^2+B^2}}\).
If we write the equation as –mx + y – b = 0, then the distance is given by: \(\dfrac{|mx_0-y_0+b|}{\sqrt{1+m^2}}\).
The point-line distance is useful in finding the equation of a parabola given the focus and the directrix given in any orientation. Visit this page to learn about the Focus-Directrix Equation of a Parabola.