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

Method signedDistance

MyGUIEngine/src/msdfgen/core/edge-segments.cpp:173–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173SignedDistance LinearSegment::signedDistance(Point2 origin, double &param) const {
174 Vector2 aq = origin-p[0];
175 Vector2 ab = p[1]-p[0];
176 param = dotProduct(aq, ab)/dotProduct(ab, ab);
177 Vector2 eq = p[param > .5]-origin;
178 double endpointDistance = eq.length();
179 if (param > 0 && param < 1) {
180 double orthoDistance = dotProduct(ab.getOrthonormal(false), aq);
181 if (fabs(orthoDistance) < endpointDistance)
182 return SignedDistance(orthoDistance, 0);
183 }
184 return SignedDistance(nonZeroSign(crossProduct(aq, ab))*endpointDistance, fabs(dotProduct(ab.normalize(), eq.normalize())));
185}
186
187SignedDistance QuadraticSegment::signedDistance(Point2 origin, double &param) const {
188 Vector2 qa = p[0]-origin;

Callers 6

addEdgeMethod · 0.80
generateSDF_legacyFunction · 0.80
generatePSDF_legacyFunction · 0.80
generateMSDF_legacyFunction · 0.80
generateMTSDF_legacyFunction · 0.80
edgeToEdgeDistanceFunction · 0.80

Calls 8

dotProductFunction · 0.85
SignedDistanceClass · 0.85
nonZeroSignFunction · 0.85
crossProductFunction · 0.85
solveCubicFunction · 0.85
getOrthonormalMethod · 0.80
lengthMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected