mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Simplify control-flow in Numerical.solveCubic() a bit.
This commit is contained in:
parent
814512f562
commit
665d154c95
1 changed files with 11 additions and 13 deletions
|
@ -265,19 +265,17 @@ var Numerical = new function() {
|
||||||
*/
|
*/
|
||||||
solveCubic: function(a, b, c, d, roots, min, max) {
|
solveCubic: function(a, b, c, d, roots, min, max) {
|
||||||
var x, b1, c2, nRoots = 0;
|
var x, b1, c2, nRoots = 0;
|
||||||
if (a === 0 || d ===0) {
|
// If a or d is zero, we only need to solve a quadratic, so we set
|
||||||
// We only need to solve a quadratic.
|
// the coefficients appropriately.
|
||||||
// So we set the coefficients appropriately.
|
if (a === 0) {
|
||||||
if (a === 0) {
|
a = b;
|
||||||
a = b;
|
b1 = c;
|
||||||
b1 = c;
|
c2 = d;
|
||||||
c2 = d;
|
x = Infinity;
|
||||||
x = Infinity;
|
} else if (d === 0) {
|
||||||
} else {
|
b1 = b;
|
||||||
b1 = b;
|
c2 = c;
|
||||||
c2 = c;
|
x = 0;
|
||||||
x = 0;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
var ec = 1 + MACHINE_EPSILON, // 1.000...002
|
var ec = 1 + MACHINE_EPSILON, // 1.000...002
|
||||||
x0, q, qd, t, r, s, tmp;
|
x0, q, qd, t, r, s, tmp;
|
||||||
|
|
Loading…
Reference in a new issue