Given a line and a point P, this returns a vector perpendicular to the line and pointing from the line to P.
myvector = VectorFromLineToPoint( A, B, P );