| 260 | } |
| 261 | |
| 262 | SegmentSegmentIntersectResult 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 | |
| 290 | bool segmentIntersectionOrder( const std::array<PreciseVertCoords2, 6> & vs ) |
| 291 | { |