From ede9ef26235640d4f14a7a7c54a450d5a1dcf3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 3 Jan 2017 00:53:54 +0100 Subject: [PATCH] Revert 7dd0b852c8560eb13c37c602e8c50e8f4f8de81d Relates to https://github.com/paperjs/paper.js/issues/1233#issuecomment-269972157 --- src/path/Curve.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index a71ac6ac..f7bda0d0 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -699,6 +699,7 @@ statics: /** @lends Curve */{ var p1 = new Point(v[0], v[1]), p2 = new Point(v[6], v[7]), epsilon = /*#=*/Numerical.EPSILON, + geomEpsilon = /*#=*/Numerical.GEOMETRIC_EPSILON, t = point.isClose(p1, epsilon) ? 0 : point.isClose(p2, epsilon) ? 1 : null; @@ -711,13 +712,16 @@ statics: /** @lends Curve */{ var count = Curve.solveCubic(v, c, coords[c], roots, 0, 1); for (var i = 0; i < count; i++) { var u = roots[i]; - if (point.isClose(Curve.getPoint(v, u), - /*#=*/Numerical.GEOMETRIC_EPSILON)) + if (point.isClose(Curve.getPoint(v, u), geomEpsilon)) return u; } } } - return t; + // Since we're comparing with geometric epsilon for any other t along + // the curve, do so as well now for the beginning and end of the curve. + return point.isClose(p1, geomEpsilon) ? 0 + : point.isClose(p2, geomEpsilon) ? 1 + : null; }, getNearestTime: function(v, point) {