1 | |
---|---|
2 | #include "SignedDistance.h" |
3 | |
4 | #include <cmath> |
5 | #include <cfloat> |
6 | |
7 | namespace msdfgen { |
8 | |
9 | SignedDistance::SignedDistance() : distance(-DBL_MAX), dot(1) { } |
10 | |
11 | SignedDistance::SignedDistance(double dist, double d) : distance(dist), dot(d) { } |
12 | |
13 | bool operator<(SignedDistance a, SignedDistance b) { |
14 | return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot < b.dot); |
15 | } |
16 | |
17 | bool operator>(SignedDistance a, SignedDistance b) { |
18 | return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot > b.dot); |
19 | } |
20 | |
21 | bool operator<=(SignedDistance a, SignedDistance b) { |
22 | return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot <= b.dot); |
23 | } |
24 | |
25 | bool operator>=(SignedDistance a, SignedDistance b) { |
26 | return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot >= b.dot); |
27 | } |
28 | |
29 | } |
30 |