Reduce Numerical.TOLERANCE to 1e-6, and use the same value across the boolean code.

Yields very good results now, across all tests.
This commit is contained in:
Jürg Lehni 2015-01-04 15:54:50 +01:00
parent ac0663bdd9
commit afc14b9634
3 changed files with 3 additions and 11 deletions

View file

@ -1073,7 +1073,6 @@ new function() { // Scope for methods that require numerical integration
// Let P be the first curve and Q be the second
var q0x = v2[0], q0y = v2[1], q3x = v2[6], q3y = v2[7],
tolerance = /*#=*/Numerical.TOLERANCE,
epsilon = 1e-10, // /*#=*/Numerical.EPSILON,
// Calculate the fat-line L for Q is the baseline l and two
// offsets which completely encloses the curve P.
d1 = getSignedDistance(q0x, q0y, q3x, q3y, v2[2], v2[3]) || 0,
@ -1089,7 +1088,7 @@ new function() { // Scope for methods that require numerical integration
dp2 = getSignedDistance(q0x, q0y, q3x, q3y, v1[4], v1[5]),
dp3 = getSignedDistance(q0x, q0y, q3x, q3y, v1[6], v1[7]),
tMinNew, tMaxNew, tDiff;
if (q0x === q3x && uMax - uMin <= epsilon && recursion > 3) {
if (q0x === q3x && uMax - uMin <= tolerance && recursion > 3) {
// The fatline of Q has converged to a point, the clipping is not
// reliable. Return the value we have even though we will miss the
// precision.

View file

@ -252,14 +252,7 @@ PathItem.inject(new function() {
* with respect to a given set of monotone curves.
*/
function getWinding(point, curves, horizontal, testContains) {
// We need to use a smaller tolerance here than in the rest of the
// library when dealing with curve time parameters and coordinates, in
// order to get really precise values for winding tests. 1e-7 was
// determined through a lot of trial and error, and boolean-test suites.
// Further decreasing it produces new errors.
// The value of 1e-7 also solves issue #559:
// https://github.com/paperjs/paper.js/issues/559
var tolerance = 1e-7,
var tolerance = /*#=*/Numerical.TOLERANCE,
tMin = tolerance,
tMax = 1 - tMin,
x = point.x,

View file

@ -63,7 +63,7 @@ var Numerical = new function() {
cos = Math.cos,
PI = Math.PI,
isFinite = Number.isFinite,
TOLERANCE = 1e-5,
TOLERANCE = 1e-6,
EPSILON = 1e-13,
MACHINE_EPSILON = 1.12e-16;