mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 06:00:56 -05:00
Do not offset bounds in cubic solver by MACHINE_EPSILON, as this is how comparisons are performed with values offset by tolerances elsewhere in the library.
Doing it differently here produced various errors in fat-line clipping and boolean code.
This commit is contained in:
parent
f0fdb804ec
commit
6359738618
1 changed files with 4 additions and 8 deletions
|
@ -229,13 +229,10 @@ var Numerical = new function() {
|
|||
// nRoots = D > MACHINE_EPSILON ? 2 : 1;
|
||||
}
|
||||
}
|
||||
var unbound = min == null,
|
||||
minE = min - MACHINE_EPSILON,
|
||||
maxE = max + MACHINE_EPSILON;
|
||||
if (isFinite(x1) && (unbound || (x1 >= minE && x1 <= maxE)))
|
||||
if (isFinite(x1) && (min == null || x1 >= min && x1 <= max))
|
||||
roots[nRoots++] = x1 < min ? min : x1 > max ? max : x1;
|
||||
if (x2 !== x1 && isFinite(x2)
|
||||
&& (unbound || (x2 >= minE && x2 <= maxE)))
|
||||
if (x2 !== x1
|
||||
&& isFinite(x2) && (min == null || x2 >= min && x2 <= max))
|
||||
roots[nRoots++] = x2 < min ? min : x2 > max ? max : x2;
|
||||
return nRoots;
|
||||
},
|
||||
|
@ -330,8 +327,7 @@ var Numerical = new function() {
|
|||
// The cubic has been deflated to a quadratic.
|
||||
var nRoots = Numerical.solveQuadratic(a, b1, c2, roots, min, max);
|
||||
if (isFinite(x) && (nRoots === 0 || x !== roots[nRoots - 1])
|
||||
&& (min == null || (x >= min - MACHINE_EPSILON
|
||||
&& x <= max + MACHINE_EPSILON)))
|
||||
&& (min == null || x >= min && x <= max))
|
||||
roots[nRoots++] = x < min ? min : x > max ? max : x;
|
||||
return nRoots;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue