aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Intersection/QuarticRoot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'experimental/Intersection/QuarticRoot.cpp')
-rw-r--r--experimental/Intersection/QuarticRoot.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/experimental/Intersection/QuarticRoot.cpp b/experimental/Intersection/QuarticRoot.cpp
index 7a95b2468c..66ce3bf415 100644
--- a/experimental/Intersection/QuarticRoot.cpp
+++ b/experimental/Intersection/QuarticRoot.cpp
@@ -46,9 +46,13 @@ static int quadraticRootsX(const double A, const double B, const double C,
/* normal form: x^2 + px + q = 0 */
const double p = B / (2 * A);
const double q = C / A;
- const double D = p * p - q;
+ double D = p * p - q;
if (D < 0) {
- return 0;
+ if (approximately_positive_squared(D)) {
+ D = 0;
+ } else {
+ return 0;
+ }
}
double sqrt_D = sqrt(D);
if (approximately_less_than_zero(sqrt_D)) {