onSegment static method
Implementation
static double onSegment(Vec2D segmentPoint1, Vec2D segmentPoint2, Vec2D pt) {
double l2 = squaredDistance(segmentPoint1, segmentPoint2);
if (l2 == 0) {
return 0;
}
return ((pt.x - segmentPoint1.x) * (segmentPoint2.x - segmentPoint1.x) +
(pt.y - segmentPoint1.y) * (segmentPoint2.y - segmentPoint1.y)) /
l2;
}