MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / ccw

Function ccw

source/MRMesh/MRPrecisePredicates2.cpp:75–107  ·  view source on GitHub ↗

see https://arxiv.org/pdf/math/9410209 Table 4-i: a=(pi_i,1, pi_i,2) b=(pi_j,1, pi_j,2)

Source from the content-addressed store, hash-verified

73// a=(pi_i,1, pi_i,2)
74// b=(pi_j,1, pi_j,2)
75bool ccw( const Vector2i & a, const Vector2i & b )
76{
77 if ( auto v = cross( Vector2i64{ a }, Vector2i64{ b } ) )
78 return v > 0; // points are in general position
79
80 // points 0, a, b are on the same line
81
82 // permute points:
83 // da.y >> da.x >> db.y >> db.x > 0
84
85 // the dominant permutation da.y > 0
86 if ( b.x )
87 return b.x < 0;
88 // permutation da.y cannot resolve the degeneration, because
89 // 1) b = 0 or
90 // 2) points 0, a, b are on the line x = 0
91
92 // next permutation da.x > 0
93 if ( b.y )
94 return b.y > 0;
95 // permutation da.x cannot resolve the degeneration, because b = 0
96
97 // next permutation db.y > 0
98 if ( a.x )
99 return a.x > 0;
100 // permutation db.y cannot resolve the degeneration, because b = 0 and a.x = 0
101
102 // a = ( da.x, a.y + da.y ) ~ ( +0, a.y )
103 // b = ( 0, db.y ) ~ ( 0, 1 )
104 // the smallest permutation db.x does not change anything here, and
105 // the rotation from a to b is always ccw independently on a.y sign
106 return true;
107}
108
109bool smaller2( const std::array<PreciseVertCoords2, 4> & vs )
110{

Callers 3

inCircleFunction · 0.70
segmentIntersectionOrderFunction · 0.70

Calls 3

crossFunction · 0.70
swapFunction · 0.70
dataMethod · 0.45

Tested by

no test coverage detected