Interface to orient2d predicate optimized for pairs.
| 1190 | |
| 1191 | // Interface to orient2d predicate optimized for pairs. |
| 1192 | static double |
| 1193 | orient2d(const Point& a, |
| 1194 | const Point& b, |
| 1195 | const Point& c) |
| 1196 | { |
| 1197 | double detsum, errbound; |
| 1198 | double orient; |
| 1199 | double detleft = (a.x - c.x) * (b.y - c.y); |
| 1200 | double detright = (a.y - c.y) * (b.x - c.x); |
| 1201 | double det = detleft - detright; |
| 1202 | |
| 1203 | if (detleft > 0.0) { |
| 1204 | if (detright <= 0.0) { |
| 1205 | return det; |
| 1206 | } else { |
| 1207 | detsum = detleft + detright; |
| 1208 | } |
| 1209 | } else if (detleft < 0.0) { |
| 1210 | if (detright >= 0.0) { |
| 1211 | return det; |
| 1212 | } else { |
| 1213 | detsum = -detleft - detright; |
| 1214 | } |
| 1215 | } else { |
| 1216 | return det; |
| 1217 | } |
| 1218 | |
| 1219 | double ccwerrboundA = std::numeric_limits<double>::epsilon() * 0.5; |
| 1220 | ccwerrboundA = (3.0 + 16.0 * ccwerrboundA) * ccwerrboundA; |
| 1221 | |
| 1222 | errbound = ccwerrboundA * detsum; |
| 1223 | if ( (det >= errbound) || (-det >= errbound) ) { |
| 1224 | return det; |
| 1225 | } |
| 1226 | |
| 1227 | Point pa, pb, pc; |
| 1228 | pa = a; |
| 1229 | pb = b; |
| 1230 | pc = c; |
| 1231 | orient = orient2dadapt(pa, pb, pc, detsum); |
| 1232 | |
| 1233 | return orient; |
| 1234 | } |
| 1235 | |
| 1236 | // Returns true if the point z lies in or on the bounding box |
| 1237 | // of a,b,c, and d. |
no test coverage detected