Index: src/pathops/SkPathOpsPoint.h |
diff --git a/src/pathops/SkPathOpsPoint.h b/src/pathops/SkPathOpsPoint.h |
index e3f722bede18219384532a11c1975064304d730d..f30f155e8fc451afe1c6c593b1b06634b7ea585e 100644 |
--- a/src/pathops/SkPathOpsPoint.h |
+++ b/src/pathops/SkPathOpsPoint.h |
@@ -58,12 +58,20 @@ struct SkDVector { |
} |
// similar to cross, this bastardization considers nearly coincident to be zero |
+ // uses ulps epsilon == 16 |
double crossCheck(const SkDVector& a) const { |
double xy = fX * a.fY; |
double yx = fY * a.fX; |
return AlmostEqualUlps(xy, yx) ? 0 : xy - yx; |
} |
+ // allow tinier numbers |
+ double crossNoNormalCheck(const SkDVector& a) const { |
+ double xy = fX * a.fY; |
+ double yx = fY * a.fX; |
+ return AlmostEqualUlpsNoNormalCheck(xy, yx) ? 0 : xy - yx; |
+ } |
+ |
double dot(const SkDVector& a) const { |
return fX * a.fX + fY * a.fY; |
} |
@@ -75,6 +83,12 @@ struct SkDVector { |
double lengthSquared() const { |
return fX * fX + fY * fY; |
} |
+ |
+ void normalize() { |
+ double inverseLength = 1 / this->length(); |
+ fX *= inverseLength; |
+ fY *= inverseLength; |
+ } |
}; |
struct SkDPoint { |
@@ -164,7 +178,7 @@ struct SkDPoint { |
float tiniest = SkTMin(SkTMin(SkTMin(a.fX, b.fX), a.fY), b.fY); |
float largest = SkTMax(SkTMax(SkTMax(a.fX, b.fX), a.fY), b.fY); |
largest = SkTMax(largest, -tiniest); |
- return AlmostPequalUlps((double) largest, largest + dist); // is dist within ULPS tolerance? |
+ return AlmostDequalUlps((double) largest, largest + dist); // is dist within ULPS tolerance? |
} |
// only used by testing |