2020-12-27 14:30:33 +01:00
|
|
|
|
|
|
|
#include "SignedDistance.h"
|
|
|
|
|
|
|
|
#include <cmath>
|
2023-06-07 15:36:35 +02:00
|
|
|
#include <cfloat>
|
2020-12-27 14:30:33 +01:00
|
|
|
|
|
|
|
namespace msdfgen {
|
|
|
|
|
2023-06-07 15:36:35 +02:00
|
|
|
SignedDistance::SignedDistance() : distance(-DBL_MAX), dot(1) { }
|
2020-12-27 14:30:33 +01: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|