From 55e2f6610a55f6b17492b7346cc8851103bf499a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ju=CC=88rg=20Lehni?= Date: Sat, 10 Jan 2015 22:06:11 +0100 Subject: [PATCH] Rename nRoots to count. --- src/util/Numerical.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/util/Numerical.js b/src/util/Numerical.js index 71d78b11..61cbd951 100644 --- a/src/util/Numerical.js +++ b/src/util/Numerical.js @@ -173,7 +173,7 @@ var Numerical = new function() { * @author Harikrishnan Gopalakrishnan */ solveQuadratic: function(a, b, c, roots, min, max) { - var nRoots = 0, + var count = 0, x1, x2 = Infinity, B = b, D; @@ -225,15 +225,15 @@ var Numerical = new function() { x2 = c / q; } // Do we actually have two real roots? - // nRoots = D > MACHINE_EPSILON ? 2 : 1; + // count = D > MACHINE_EPSILON ? 2 : 1; } } if (isFinite(x1) && (min == null || x1 >= min && x1 <= max)) - roots[nRoots++] = x1; + roots[count++] = x1; if (x2 !== x1 && isFinite(x2) && (min == null || x2 >= min && x2 <= max)) - roots[nRoots++] = x2; - return nRoots; + roots[count++] = x2; + return count; }, /** @@ -264,7 +264,7 @@ var Numerical = new function() { * @author Harikrishnan Gopalakrishnan */ solveCubic: function(a, b, c, d, roots, min, max) { - var x, b1, c2, nRoots = 0; + var x, b1, c2, count = 0; // If a or d is zero, we only need to solve a quadratic, so we set // the coefficients appropriately. if (a === 0) { @@ -322,11 +322,11 @@ var Numerical = new function() { } } // The cubic has been deflated to a quadratic. - var nRoots = Numerical.solveQuadratic(a, b1, c2, roots, min, max); - if (isFinite(x) && (nRoots === 0 || x !== roots[nRoots - 1]) + var count = Numerical.solveQuadratic(a, b1, c2, roots, min, max); + if (isFinite(x) && (count === 0 || x !== roots[count - 1]) && (min == null || x >= min && x <= max)) - roots[nRoots++] = x; - return nRoots; + roots[count++] = x; + return count; } }; };