mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Clean up and simplify code a bit further.
This commit is contained in:
parent
7462fe0b70
commit
6a11532322
2 changed files with 7 additions and 8 deletions
|
@ -1036,11 +1036,10 @@ new function() { // Scope for methods that require numerical integration
|
||||||
start = t;
|
start = t;
|
||||||
return length - offset;
|
return length - offset;
|
||||||
}
|
}
|
||||||
return Numerical.findRoot(f, ds,
|
// Start with out initial guess for x.
|
||||||
// Start with out initial guess for x.
|
// NOTE: guess is a negative value when not looking forward.
|
||||||
// NOTE: guess is a negative value when not looking forward.
|
return Numerical.findRoot(f, ds, start + guess, a, b, 16,
|
||||||
forward ? a + guess : b + guess,
|
/*#=*/Numerical.TOLERANCE);
|
||||||
a, b, 16, /*#=*/Numerical.TOLERANCE);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, new function() { // Scope for intersection using bezier fat-line clipping
|
}, new function() { // Scope for intersection using bezier fat-line clipping
|
||||||
|
|
|
@ -101,7 +101,7 @@ var Numerical = new function() {
|
||||||
integrate: function(f, a, b, n) {
|
integrate: function(f, a, b, n) {
|
||||||
var x = abscissas[n - 2],
|
var x = abscissas[n - 2],
|
||||||
w = weights[n - 2],
|
w = weights[n - 2],
|
||||||
A = 0.5 * (b - a),
|
A = (b - a) * 0.5,
|
||||||
B = A + a,
|
B = A + a,
|
||||||
i = 0,
|
i = 0,
|
||||||
m = (n + 1) >> 1,
|
m = (n + 1) >> 1,
|
||||||
|
@ -134,10 +134,10 @@ var Numerical = new function() {
|
||||||
// intercept is larger than lower / smaller than upper.
|
// intercept is larger than lower / smaller than upper.
|
||||||
if (fx > 0) {
|
if (fx > 0) {
|
||||||
b = x;
|
b = x;
|
||||||
x = nx <= a ? 0.5 * (a + b) : nx;
|
x = nx <= a ? (a + b) * 0.5 : nx;
|
||||||
} else {
|
} else {
|
||||||
a = x;
|
a = x;
|
||||||
x = nx >= b ? 0.5 * (a + b) : nx;
|
x = nx >= b ? (a + b) * 0.5 : nx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Return the best result even though we haven't gotten close
|
// Return the best result even though we haven't gotten close
|
||||||
|
|
Loading…
Reference in a new issue