return line.getProjection(v).addToPoint(lineStart);
}
public static <P extends Point> P projectPointToSegment(P point,
P segmentStart, P segmentEnd) {
PointVector v = PointVector.create(segmentStart, point);
PointVector line = PointVector.create(segmentStart, segmentEnd);
P p = line.getProjection(v).addToPoint(segmentStart);
if (isBetween(p, segmentStart, segmentEnd))
return p;
double a = p.getDistance(segmentStart);
double b = p.getDistance(segmentEnd);
return a <= b ? segmentStart : segmentEnd;