Introduce separate epsilon for fat-line clipping code, and reduce curve-time epsilon.

This commit is contained in:
Jürg Lehni 2015-10-21 23:44:24 +02:00
parent e9c3e72f60
commit bafb6794a6
2 changed files with 8 additions and 4 deletions

View file

@ -1422,7 +1422,6 @@ new function() { // Scope for intersection using bezier fat-line clipping
return;
// Let P be the first curve and Q be the second
var q0x = v2[0], q0y = v2[1], q3x = v2[6], q3y = v2[7],
epsilon = /*#=*/(Numerical.CURVETIME_EPSILON / 10),
getSignedDistance = Line.getSignedDistance,
// Calculate the fat-line L for Q is the baseline l and two
// offsets which completely encloses the curve P.
@ -1479,7 +1478,8 @@ new function() { // Scope for intersection using bezier fat-line clipping
parts[1], v1, c2, c1, locations, param,
t, uMax, tMinNew, tMaxNew, tDiff, !reverse, recursion);
}
} else if (Math.max(uMax - uMin, tMaxNew - tMinNew) < epsilon) {
} else if (Math.max(uMax - uMin, tMaxNew - tMinNew)
< /*#=*/Numerical.CLIPPING_EPSILON) {
// We have isolated the intersection with sufficient precision
var t1 = tMinNew + (tMaxNew - tMinNew) / 2,
t2 = uMin + (uMax - uMin) / 2;

View file

@ -99,13 +99,13 @@ var Numerical = new function() {
* cannot be smaller, because errors add up to around 8e-7 in the bezier
* fat-line clipping code as a result of recursive sub-division.
*/
CURVETIME_EPSILON: 8e-7,
CURVETIME_EPSILON: 4e-7, // NOTE: 2e-7 doesn't work in some edge-cases!
/**
* The epsilon to be used when performing "geometric" checks, such as
* point distances and examining cross products to check for
* collinearity.
*/
GEOMETRIC_EPSILON: 4e-7, // NOTE: 1e-7 doesn't work in some edge-cases!
GEOMETRIC_EPSILON: 4e-7, // NOTE: 2e-7 doesn't work in some edge-cases!
/**
* The epsilon to be used when performing winding contribution checks.
*/
@ -115,6 +115,10 @@ var Numerical = new function() {
* as examining cross products to check for collinearity.
*/
TRIGONOMETRIC_EPSILON: 1e-7,
/**
* The epsilon to be used in the fatline clipping code.
*/
CLIPPING_EPSILON: 1e-7,
// Kappa, see: http://www.whizkidtech.redprince.net/bezier/circle/kappa/
KAPPA: 4 * (sqrt(2) - 1) / 3,