From e8219b71396d5891cd1b232092f18b3b7511ef7a Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 4 Nov 2020 10:30:37 +0300 Subject: [PATCH] Fix error in quadratic solver --- libs/geom/include/psemek/geom/math.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/geom/include/psemek/geom/math.hpp b/libs/geom/include/psemek/geom/math.hpp index 8eea2b31..6b5a69f6 100644 --- a/libs/geom/include/psemek/geom/math.hpp +++ b/libs/geom/include/psemek/geom/math.hpp @@ -40,7 +40,7 @@ namespace psemek::geom auto const D = b * b - 4 * a * c; if (D < 0) return std::nullopt; - auto t = - (b + (b > 0 ? 1 : -1) * std::sqrt(D)); + auto t = - (b + (b > 0 ? 1 : -1) * std::sqrt(D)) / 2; auto x1 = t / a; auto x2 = c / t;