onsegment
Onsegment is a geometric predicate used to determine whether a point lies on a closed line segment AB. A point P is on segment AB if P lies on the line through A and B and is between A and B, with endpoints included. Equivalently, there exists a parameter t in [0,1] such that P = A + t(B − A). This condition applies in both two- and three-dimensional space.
A practical way to test on-segment is to first check collinearity of A, B, and P, and
In practice, on-segment tests appear in polygon processing, segment-intersection algorithms, computer graphics, and geographic information systems.