Fix check for quadratic curve by using the right coefficient (a instead of d), and checking with tolerance.

This commit is contained in:
Jürg Lehni 2011-07-05 17:03:49 +02:00
parent ccd4113ba3
commit 99f6597615

View file

@ -155,7 +155,7 @@ var Numerical = new function() {
solveCubic: function(a, b, c, d, tolerance) {
// After Numerical Recipes in C, 2nd edition, Press et al.,
// 5.6, Quadratic and Cubic Equations
if (d == 0)
if (abs(a) < tolerance)
return Numerical.solveQuadratic(b, c, d, tolerance);
// Normalize
b /= a;