mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Correct tolrance check (±EPSILON) in numerical solving methods.
This commit is contained in:
parent
274f1a4b55
commit
d64df44a78
1 changed files with 11 additions and 3 deletions
|
@ -131,13 +131,17 @@ var Numerical = new function() {
|
|||
count = 0;
|
||||
|
||||
function add(root) {
|
||||
if (unbound || root >= min && root <= max)
|
||||
if (unbound || root >= minE && root <= maxE){
|
||||
root = root < min ? min : (root > max ? max : root);
|
||||
roots[count++] = root;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// Code ported over and adapted from Uintah library (MIT license).
|
||||
var epsilon = this.EPSILON;
|
||||
var epsilon = this.EPSILON,
|
||||
minE = unbound ? undefined : min - epsilon,
|
||||
maxE = unbound ? undefined : max + epsilon;
|
||||
// If a is 0, equation is actually linear, return 0 or 1 easy roots.
|
||||
if (abs(a) < epsilon) {
|
||||
if (abs(b) >= epsilon)
|
||||
|
@ -171,11 +175,15 @@ var Numerical = new function() {
|
|||
return Numerical.solveQuadratic(b, c, d, roots, min, max);
|
||||
|
||||
var unbound = min === undefined,
|
||||
minE = unbound ? undefined : min - epsilon,
|
||||
maxE = unbound ? undefined : max + epsilon,
|
||||
count = 0;
|
||||
|
||||
function add(root) {
|
||||
if (unbound || root >= min && root <= max)
|
||||
if (unbound || root >= minE && root <= maxE){
|
||||
root = root < min ? min : (root > max ? max : root);
|
||||
roots[count++] = root;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue