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

Function doSegmentSegmentIntersect

source/MRMesh/MRPrecisePredicates2.cpp:262–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262SegmentSegmentIntersectResult doSegmentSegmentIntersect( const std::array<PreciseVertCoords2, 4> & vs )
263{
264 SegmentSegmentIntersectResult res;
265 constexpr int a = 0;
266 constexpr int b = 1;
267 constexpr int c = 2;
268 constexpr int d = 3;
269
270 auto ccw = [&]( int p, int q, int r )
271 {
272 return MR::ccw( { vs[p], vs[q], vs[r] } );
273 };
274
275 const auto abc = ccw( a, b, c );
276 res.cIsLeftFromAB = abc;
277 const auto abd = ccw( a, b, d );
278 if ( abc == abd )
279 return res; // segment CD is located at one side of the line AB
280
281 const auto cda = ccw( c, d, a );
282 const auto cdb = ccw( c, d, b );
283 if ( cda == cdb )
284 return res; // segment AB is located at one side of the line CD
285
286 res.doIntersect = true;
287 return res;
288}
289
290bool segmentIntersectionOrder( const std::array<PreciseVertCoords2, 6> & vs )
291{

Callers 2

TESTFunction · 0.85
segmentIntersectionOrderFunction · 0.85

Calls 1

ccwFunction · 0.70

Tested by 1

TESTFunction · 0.68