The perpendicular (shortest) distance from a point to a line is given by the formula
d= (Ax0+By0+C)/sqrt(A2+B2) where the line is Ax + By + C = 0 and the point is (x0,y0).
The derivation of this formula can easily be found on the Internet, but it is too long to reproduce here.