2
0

SignedDistance.cpp 935 B

123456789101112131415161718192021222324252627282930
  1. #include "SignedDistance.h"
  2. #include <cmath>
  3. namespace msdfgen {
  4. const SignedDistance SignedDistance::INFINITE(-1e240, 1);
  5. SignedDistance::SignedDistance() : distance(-1e240), 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. }