Point belongs to segment?


Is there a standard way to determine if point belongs to line segment bounded by 2 points?

Currently I project point to segment, calculate distance from initial point to projection point and compare it with Precision::Confusion().

Stephane Routelous's picture

Let's say your segment is between P1 and P2, and P is your point.

gp_Vec V1(P,P1);
gp_Vec V2(P,P2);

Standard_Boolean PBelongToSeg = V1.IsParallel(V2,Precision::Angular());

compute the 2 gp_Vec from