| 179 | } |
| 180 | |
| 181 | TriangleSegmentIntersectResult doTriangleSegmentIntersect( const std::array<PreciseVertCoords, 5> & vs ) |
| 182 | { |
| 183 | TriangleSegmentIntersectResult res; |
| 184 | constexpr int a = 0; |
| 185 | constexpr int b = 1; |
| 186 | constexpr int c = 2; |
| 187 | constexpr int d = 3; |
| 188 | constexpr int e = 4; |
| 189 | |
| 190 | auto orient3d = [&]( int p, int q, int r, int s ) |
| 191 | { |
| 192 | return MR::orient3d( { vs[p], vs[q], vs[r], vs[s] } ); |
| 193 | }; |
| 194 | |
| 195 | const auto abcd = orient3d( a, b, c, d ); |
| 196 | res.dIsLeftFromABC = abcd; |
| 197 | const auto abce = orient3d( a, b, c, e ); |
| 198 | if ( abcd == abce ) |
| 199 | return res; // segment DE is located at one side of the plane ABC |
| 200 | |
| 201 | const auto dabe = orient3d( a, b, d, e ); |
| 202 | const auto dbce = orient3d( b, c, d, e ); |
| 203 | if ( dabe != dbce ) |
| 204 | return res; // segment AC is located at one side of the plane DEB |
| 205 | |
| 206 | const auto dcae = !orient3d( a, c, d, e ); // '!' is due to inverted order of a and c |
| 207 | if ( dbce != dcae ) |
| 208 | return res; // segment AB is located at one side of the plane DEC |
| 209 | |
| 210 | assert ( dcae == dabe ); // segment BC is crossed by the plane DEA |
| 211 | |
| 212 | res.doIntersect = true; |
| 213 | return res; |
| 214 | } |
| 215 | |
| 216 | bool segmentIntersectionOrder( const std::array<PreciseVertCoords, 8> & vs ) |
| 217 | { |