Improve reliability of Curve.getIntersection()

Reduce epsilon when checking against curve end points from GEOMETRIC_EPSILON to EPSILON.

Coses #1174
This commit is contained in:
Jürg Lehni 2016-09-24 14:28:43 -04:00
parent 3eafd5256a
commit b37b8cc495
2 changed files with 21 additions and 1 deletions

View file

@ -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],

View file

@ -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 }
]);
})