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

Method distanceToPerpendicularDistance

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

Source from the content-addressed store, hash-verified

26}
27
28void EdgeSegment::distanceToPerpendicularDistance(SignedDistance &distance, Point2 origin, double param) const {
29 if (param < 0) {
30 Vector2 dir = direction(0).normalize();
31 Vector2 aq = origin-point(0);
32 double ts = dotProduct(aq, dir);
33 if (ts < 0) {
34 double perpendicularDistance = crossProduct(aq, dir);
35 if (fabs(perpendicularDistance) <= fabs(distance.distance)) {
36 distance.distance = perpendicularDistance;
37 distance.dot = 0;
38 }
39 }
40 } else if (param > 1) {
41 Vector2 dir = direction(1).normalize();
42 Vector2 bq = origin-point(1);
43 double ts = dotProduct(bq, dir);
44 if (ts > 0) {
45 double perpendicularDistance = crossProduct(bq, dir);
46 if (fabs(perpendicularDistance) <= fabs(distance.distance)) {
47 distance.distance = perpendicularDistance;
48 distance.dot = 0;
49 }
50 }
51 }
52}
53
54LinearSegment::LinearSegment(Point2 p0, Point2 p1, EdgeColor edgeColor) : EdgeSegment(edgeColor) {
55 p[0] = p0;

Callers 4

computeDistanceMethod · 0.80
generatePSDF_legacyFunction · 0.80
generateMSDF_legacyFunction · 0.80
generateMTSDF_legacyFunction · 0.80

Calls 3

dotProductFunction · 0.85
crossProductFunction · 0.85
normalizeMethod · 0.45

Tested by

no test coverage detected