| 262 | #define EDGE_DISTANCE_PRECISION 16 |
| 263 | |
| 264 | static double edgeToEdgeDistance(const EdgeSegment &a, const EdgeSegment &b, int precision) { |
| 265 | if (a.point(0) == b.point(0) || a.point(0) == b.point(1) || a.point(1) == b.point(0) || a.point(1) == b.point(1)) |
| 266 | return 0; |
| 267 | double iFac = 1./precision; |
| 268 | double minDistance = (b.point(0)-a.point(0)).length(); |
| 269 | for (int i = 0; i <= precision; ++i) { |
| 270 | double t = iFac*i; |
| 271 | double d = fabs(a.signedDistance(b.point(t), t).distance); |
| 272 | minDistance = min(minDistance, d); |
| 273 | } |
| 274 | for (int i = 0; i <= precision; ++i) { |
| 275 | double t = iFac*i; |
| 276 | double d = fabs(b.signedDistance(a.point(t), t).distance); |
| 277 | minDistance = min(minDistance, d); |
| 278 | } |
| 279 | return minDistance; |
| 280 | } |
| 281 | |
| 282 | static double splineToSplineDistance(EdgeSegment *const *edgeSegments, int aStart, int aEnd, int bStart, int bEnd, int precision) { |
| 283 | double minDistance = DBL_MAX; |
no test coverage detected