MCPcopy Create free account
hub / github.com/MyGUI/mygui / edgeToEdgeDistance

Function edgeToEdgeDistance

MyGUIEngine/src/msdfgen/core/edge-coloring.cpp:264–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262#define EDGE_DISTANCE_PRECISION 16
263
264static 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
282static double splineToSplineDistance(EdgeSegment *const *edgeSegments, int aStart, int aEnd, int bStart, int bEnd, int precision) {
283 double minDistance = DBL_MAX;

Callers 1

splineToSplineDistanceFunction · 0.85

Calls 4

minFunction · 0.85
signedDistanceMethod · 0.80
pointMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected