diff options
Diffstat (limited to 'src/pathops/SkPathOpsPoint.h')
-rw-r--r-- | src/pathops/SkPathOpsPoint.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/pathops/SkPathOpsPoint.h b/src/pathops/SkPathOpsPoint.h index e3f722bede..f30f155e8f 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 |