MCPcopy Create free account
hub / github.com/comaps/comaps / IsPointOnSegmentEps

Function IsPointOnSegmentEps

libs/geometry/segment2d.cpp:12–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10namespace m2
11{
12bool IsPointOnSegmentEps(PointD const & pt, PointD const & p1, PointD const & p2, double eps)
13{
14 double const t = robust::OrientedS(p1, p2, pt);
15
16 if (std::fabs(t) > eps)
17 return false;
18
19 double minX = p1.x;
20 double maxX = p2.x;
21 if (maxX < minX)
22 std::swap(maxX, minX);
23
24 double minY = p1.y;
25 double maxY = p2.y;
26 if (maxY < minY)
27 std::swap(maxY, minY);
28
29 return pt.x >= minX - eps && pt.x <= maxX + eps && pt.y >= minY - eps && pt.y <= maxY + eps;
30}
31
32bool IsPointOnSegment(PointD const & pt, PointD const & p1, PointD const & p2)
33{

Callers 6

GetCoverageMethod · 0.85
GetMatchingScoreMethod · 0.85
IsPointOnSegmentFunction · 0.85
IntersectFunction · 0.85
HasPointMethod · 0.85
OnEdgeFunction · 0.85

Calls 2

OrientedSFunction · 0.85
swapFunction · 0.70

Tested by

no test coverage detected