mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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;
|
||||
return length - offset;
|
||||
}
|
||||
return Numerical.findRoot(f, ds,
|
||||
// Start with out initial guess for x.
|
||||
// NOTE: guess is a negative value when not looking forward.
|
||||
forward ? a + guess : b + guess,
|
||||
a, b, 16, /*#=*/Numerical.TOLERANCE);
|
||||
// Start with out initial guess for x.
|
||||
// NOTE: guess is a negative value when not looking forward.
|
||||
return Numerical.findRoot(f, ds, start + guess, a, b, 16,
|
||||
/*#=*/Numerical.TOLERANCE);
|
||||
}
|
||||
};
|
||||
}, new function() { // Scope for intersection using bezier fat-line clipping
|
||||
|
|
|
@ -101,7 +101,7 @@ var Numerical = new function() {
|
|||
integrate: function(f, a, b, n) {
|
||||
var x = abscissas[n - 2],
|
||||
w = weights[n - 2],
|
||||
A = 0.5 * (b - a),
|
||||
A = (b - a) * 0.5,
|
||||
B = A + a,
|
||||
i = 0,
|
||||
m = (n + 1) >> 1,
|
||||
|
@ -134,10 +134,10 @@ var Numerical = new function() {
|
|||
// intercept is larger than lower / smaller than upper.
|
||||
if (fx > 0) {
|
||||
b = x;
|
||||
x = nx <= a ? 0.5 * (a + b) : nx;
|
||||
x = nx <= a ? (a + b) * 0.5 : nx;
|
||||
} else {
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue