Point-to-Line Distance

The distance from a point $(x',y')$ to a line (line-point distance), measured orthogonally—that is, as the distance between the given point and the nearest point on the line—is:

\begin{displaymath}
d = \frac{\vert a x' + b y' + c \vert}{ \sqrt{a^2 + b^2} }
\end{displaymath} (1.67)

In the n-dimensional case, the point $\mathbf {x}$ on the line defined by Equation (1.58) that is nearest to a point $\mathbf{m}$ is the point for which the scalar $t$ takes the value

\begin{displaymath}
t = (\mathbf{m} - \mathbf{p}) \cdot \mathbf{v}
\end{displaymath} (1.68)

the scalar projection of the segment $\mathbf{m}-\mathbf{p}$ onto the direction vector $\mathbf{v}$.

This formulation is particularly useful for measuring the distance between a point $\mathbf{m}$ and a segment $(\mathbf{p},\mathbf{q})$, using the line generated as in Equation (1.65). In this case, a value of $t$ between $[0,1]$ indicates that the point nearest to $\mathbf{m}$ lies within the segment, since it is the scalar projection of the segment $(\mathbf{p},\mathbf{m})$ onto the segment $(\mathbf{p},\mathbf{q})$.

Finally, Section 1.6.10, Equation (1.90), will show how to find the point on a hyperplane nearest to an arbitrary point. This formulation also applies to lines written in hyperplane form. Consequently, the point $(x,y)$ on the line $(a,b,c)$ nearest to the point $(x',y')$ is

\begin{displaymath}
(x,y) = \left( x' - a \frac{a x' + b y' + c}{a^2+b^2}, y' - b \frac{a x' + b y' + c}{a^2+b^2} \right)
\end{displaymath} (1.69)

Paolo medici
2026-10-19