mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -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) {
|
||||
var x, b1, c2, nRoots = 0;
|
||||
if (a === 0 || d ===0) {
|
||||
// We only need to solve a quadratic.
|
||||
// So we set the coefficients appropriately.
|
||||
if (a === 0) {
|
||||
a = b;
|
||||
b1 = c;
|
||||
c2 = d;
|
||||
x = Infinity;
|
||||
} else {
|
||||
b1 = b;
|
||||
c2 = c;
|
||||
x = 0;
|
||||
}
|
||||
// If a or d is zero, we only need to solve a quadratic, so we set
|
||||
// the coefficients appropriately.
|
||||
if (a === 0) {
|
||||
a = b;
|
||||
b1 = c;
|
||||
c2 = d;
|
||||
x = Infinity;
|
||||
} else if (d === 0) {
|
||||
b1 = b;
|
||||
c2 = c;
|
||||
x = 0;
|
||||
} else {
|
||||
var ec = 1 + MACHINE_EPSILON, // 1.000...002
|
||||
x0, q, qd, t, r, s, tmp;
|
||||
|
|
Loading…
Reference in a new issue