ClosestPointOnSegment

function ClosestPointOnSegment(const pt, segPt1, segPt2: TPointD): TPointD;

Returns the point on the line segment (defined by segPt1 and segPt2) that's closest to 'pt'.