nearestPointOnSegment function

Nearest point on segment