From ff6484ba8caa9f1e8484da1ca9bf9ded2fc99c02 Mon Sep 17 00:00:00 2001 From: sapics Date: Thu, 16 Jun 2016 14:37:07 +0900 Subject: [PATCH] Fix to cover the case when Numerical.solveQuadratic return -1 in Numerical.solveCubic --- src/util/Numerical.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/Numerical.js b/src/util/Numerical.js index 44050fbb..b81718d8 100644 --- a/src/util/Numerical.js +++ b/src/util/Numerical.js @@ -356,7 +356,8 @@ var Numerical = new function() { } // The cubic has been deflated to a quadratic. var count = Numerical.solveQuadratic(a, b1, c2, roots, min, max); - if (isFinite(x) && (count === 0 || x !== roots[count - 1]) + if (isFinite(x) && count >= 0 + && (count === 0 || x !== roots[count - 1]) && (min == null || x > min - EPSILON && x < max + EPSILON)) roots[count++] = min == null ? x : clamp(x, min, max); return count;