summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-11-18 01:54:52 -0500
committerTavian Barnes <tavianator@gmail.com>2010-11-18 01:54:52 -0500
commit1fb1d68006b524ba85a5e71e72457369f3d3f26d (patch)
treef73efaa52f0a6eeff2143c0b2913c8ab8eace439 /libdimension
parent3ea7a970eaeb0165e4d2d8c5c2f40ac137b57ca6 (diff)
downloaddimension-1fb1d68006b524ba85a5e71e72457369f3d3f26d.tar.xz
Compare the cubic discriminant to 0 rather than dmnsn_epsilon.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/polynomial.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libdimension/polynomial.c b/libdimension/polynomial.c
index 68970ee..09a2bb0 100644
--- a/libdimension/polynomial.c
+++ b/libdimension/polynomial.c
@@ -359,7 +359,7 @@ dmnsn_solve_cubic(double poly[4], double x[3])
double disc = 4.0*p*p*p + 27.0*q*q;
double bdiv3 = poly[2]/3;
- if (disc <= -dmnsn_epsilon) {
+ if (disc < 0.0) {
/* Three real roots -- this implies p < 0 */
double msqrtp3 = -sqrt(-p/3.0);
double theta = acos(3*q/(2*p*msqrtp3))/3.0;
@@ -373,7 +373,7 @@ dmnsn_solve_cubic(double poly[4], double x[3])
return 3;
else if (x[1] >= dmnsn_epsilon)
return 2;
- } else if (disc >= dmnsn_epsilon) {
+ } else if (disc > 0.0) {
/* One real root */
double cbrtdiscq = cbrt(sqrt(disc/108.0) + fabs(q)/2.0);
double abst = cbrtdiscq - p/(3.0*cbrtdiscq);