The distance from the point
q to the closest point the line segment
from p1 to p2 is returned. The line segment is used, not an infinitely
extended line, so if
q is in line with p1 to p2, but not between
p1 and p2, the closest distance to the line segment is returned.