2020-12-27 13:30:33 +00:00
|
|
|
|
|
|
|
#include "SignedDistance.h"
|
|
|
|
|
|
|
|
#include <cmath>
|
2023-06-07 13:36:35 +00:00
|
|
|
#include <cfloat>
|
2020-12-27 13:30:33 +00:00
|
|
|
|
|
|
|
namespace msdfgen {
|
|
|
|
|
2023-06-07 13:36:35 +00:00
|
|
|
SignedDistance::SignedDistance() : distance(-DBL_MAX), dot(1) { }
|
2020-12-27 13:30:33 +00:00
|
|
|
|
|
|
|
SignedDistance::SignedDistance(double dist, double d) : distance(dist), dot(d) { }
|
|
|
|
|
|
|
|
bool operator<(SignedDistance a, SignedDistance b) {
|
|
|
|
return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot < b.dot);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator>(SignedDistance a, SignedDistance b) {
|
|
|
|
return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot > b.dot);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<=(SignedDistance a, SignedDistance b) {
|
|
|
|
return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot <= b.dot);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator>=(SignedDistance a, SignedDistance b) {
|
|
|
|
return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot >= b.dot);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|