SignedDistance.cpp 896 B

123456789101112131415161718192021222324252627282930
  1. #include "SignedDistance.h"
  2. #include <cmath>
  3. #include <cfloat>
  4. namespace msdfgen {
  5. SignedDistance::SignedDistance() : distance(-DBL_MAX), dot(1) { }
  6. SignedDistance::SignedDistance(double dist, double d) : distance(dist), dot(d) { }
  7. bool operator<(SignedDistance a, SignedDistance b) {
  8. return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot < b.dot);
  9. }
  10. bool operator>(SignedDistance a, SignedDistance b) {
  11. return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot > b.dot);
  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. bool operator>=(SignedDistance a, SignedDistance b) {
  17. return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot >= b.dot);
  18. }
  19. }