Fix to cover the case when Numerical.solveQuadratic return -1 in Numerical.solveCubic

This commit is contained in:
sapics 2016-06-16 14:37:07 +09:00
parent c5b4828ace
commit ff6484ba8c

View file

@ -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;