Perpendicular Distance from Straight Line in Plane to Point/Normal Form

Theorem
Let $\LL$ be a straight line in the Cartesian plane.

Let $\LL$ be expressed in normal form:
 * $x \cos \alpha + y \sin \alpha = p$

Let $P$ be a point in the cartesian plane whose coordinates are given by:
 * $P = \tuple {x_0, y_0}$

Then the perpendicular distance $d$ from $P$ to $\LL$ is given by:


 * $\pm d = x_0 \cos \alpha = y_0 \sin \alpha - p$

where $\pm$ depends on whether $P$ is on the same side of $\LL$ as the origin $O$.

Proof
First suppose that $P$ is on the opposite side of $\LL$ from the origin $O$.

Let $MP$ be the ordinate of $P$.

Let $N$ be the point of intersection between $\LL$ and the perpendicular through $O$.

Let $ON$ be produced to $N'$ where $PN'$ is the straight line through $P$ parallel to $\LL$.


 * Distance-from-straight-line-normal-form.png

We have that:
 * $d = NN'$

and so:
 * $x_0 \cos \alpha + y_0 \sin \alpha = ON' = p + d$

That is:
 * $d = x_0 \cos \alpha + y_0 \sin \alpha - p$

By a similar construction, if $P$ is on the same side of $\LL$ as the origin $O$:
 * $-d = x_0 \cos \alpha + y_0 \sin \alpha - p$