From b37b8cc495cae195101da22de5bf9ab96f39adca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 24 Sep 2016 14:28:43 -0400 Subject: [PATCH] Improve reliability of Curve.getIntersection() Reduce epsilon when checking against curve end points from GEOMETRIC_EPSILON to EPSILON. Coses #1174 --- src/path/Curve.js | 2 +- test/tests/Path_Intersections.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index 620458d3..544157cb 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -1908,7 +1908,7 @@ new function() { // Scope for intersection using bezier fat-line clipping // a little optimization, we can scale the handles with 0.75 // before calculating the control bounds and still be sure that // the curve is fully contained. - var epsilon = /*#=*/Numerical.GEOMETRIC_EPSILON, + var epsilon = /*#=*/Numerical.EPSILON, c1p1x = v1[0], c1p1y = v1[1], c1p2x = v1[6], c1p2y = v1[7], c2p1x = v2[0], c2p1y = v2[1], diff --git a/test/tests/Path_Intersections.js b/test/tests/Path_Intersections.js index 754c2507..f36bf2a7 100644 --- a/test/tests/Path_Intersections.js +++ b/test/tests/Path_Intersections.js @@ -172,3 +172,23 @@ test('#1088', function() { { point: { x: 309.99726, y: 309.5004975367957 }, index: 0, time: 0.17182, crossing: true } ]); }); + +test('#1174', function() { + var path1 = new paper.Path({ + segments: [ + [20, 60], + [20, 100], + [150, 100] + ] + }); + var path2 = new paper.Path({ + segments: [ + [20, 140], + [20, 100.00000001], + [150, 98] + ] + }); + testIntersection(path1.getIntersections(path2), [ + { point: { x: 20, y: 100 }, index: 1, time: 0.00004, crossing: true } + ]); +})