Point-Line Distance

Result
If line L has the normalized direction vector l, and A is a point on L, the distance from L to a point P is: dist(P,L) = |AP x l| where AP is the vector from A to P, x is the cross product, and |v| is the magnitude of the vector v.

Derivation
P    | |d = dist(P,L) A___|______ L

L is defined by the normalized direction vector l and A is a point on L.

By d we denote the distance from P to L.

.  v /| / |d /__|_____ l

We can also define the vector v = AP.

If we define a parallelogram spanned by v and l, the area is:

area = |v x l|    (x is the cross product)

The area of the parallelogram can also be computed as the magnitude of the base times the height (= d), which, since l is normalized, is:

area = |l| * d = d

So we have:

d = area = |v x l|