From 4c61153bd4602add6cf8fd5621954b47e84cba2b Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 20 Jul 2016 16:32:20 +0200 Subject: [PATCH 1/2] Improve fat line clipping to fix #1088 Only alternate curves in addCurveIntersections() if interval on other curve is not tight enough yet. --- src/path/Curve.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index de49a176..defbfe1e 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -1709,9 +1709,15 @@ new function() { // Scope for intersection using bezier fat-line clipping u, uMax, tMinNew, tMaxNew, !flip, recursion, calls); } } else { // Iterate - calls = addCurveIntersections( - v2, v1, c2, c1, locations, param, + if (uMax - uMin >= /*#=*/Numerical.CLIPPING_EPSILON) { + calls = addCurveIntersections(v2, v1, c2, c1, locations, param, uMin, uMax, tMinNew, tMaxNew, !flip, recursion, calls); + } else { + // The interval on the other curve is already tight enough, + // therefore we keep iterating on the same curve. + calls = addCurveIntersections(v1, v2, c1, c2, locations, param, + tMinNew, tMaxNew, uMin, uMax, flip, recursion, calls); + } } } return calls; From 381e92501a5eb5e9dd0c27fe7ebed29f2df4b1fc Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 20 Jul 2016 16:33:13 +0200 Subject: [PATCH 2/2] Add test for #1088 --- test/tests/Path_Intersections.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/tests/Path_Intersections.js b/test/tests/Path_Intersections.js index 3b99b036..4d37c09f 100644 --- a/test/tests/Path_Intersections.js +++ b/test/tests/Path_Intersections.js @@ -152,3 +152,17 @@ test('#1074', function() { { point: { x: 349.98644, y: 126.84 } , index: 4, time: 0, crossing: true } ]); }); + +test('#1088', function() { + var path1 = new paper.Path({segments:[ + [314.48576574722523, 308.77472829145444, 8.651222275575492, -2.220498935022104, -8.651222275575492, 2.220498935022105], + [290.40724577164383, 302.0497467665447, 6.2486166726329975, 6.3819316872198515, -0.012648799703259704, -0.012918663419550348] + ], closed:false}); + var path2 = new paper.Path({segments:[ + [328.02746577749963, 300.1256389868014, 7.902769748335459, -10.046794724901815, -2.5352164811920375e-11, 3.2230218494078144e-11], + [309.7443037372522, 309.63202128991924, 5.4001247917767614e-11, -2.9558577807620168e-12, -6.666656713343759, 0.3629571641783996] + ], closed:false}); + testIntersection(path1.getIntersections(path2), [ + { point: { x: 309.99726, y: 309.5004975367957 }, index: 0, time: 0.17182, crossing: true } + ]); +});