The perpendicular distance from a point M0(x0,y0) to a line Δ:ax+by+c=0 (with a2+b2>0) is d(M0,Δ)=a2+b2∣ax0+by0+c∣.
Why is it true?
The shortest segment from M0 to Δ runs along the normal direction n=(a,b), so projecting the vector from any point on Δ to M0 onto the unit normal ∣n∣n measures the exact perpendicular distance.
Proof sketch
Let H(xH,yH) be the orthogonal projection of M0(x0,y0) onto Δ. Because HM0 is parallel to the normal vector n=(a,b), there exists a scalar t∈R such that HM0=tn=(ta,tb), which gives xH=x0−ta and yH=y0−tb.
Since H lies on Δ, its coordinates satisfy axH+byH+c=0. Substituting xH and yH yields a(x0−ta)+b(y0−tb)+c=0, or ax0+by0+c−t(a2+b2)=0.
Solving for t gives t=a2+b2ax0+by0+c. Therefore the distance is d(M0,Δ)=∣HM0∣=∣t∣∣n∣=a2+b2∣ax0+by0+c∣a2+b2=a2+b2∣ax0+by0+c∣.