diff --git a/libs/geom/include/psemek/geom/math.hpp b/libs/geom/include/psemek/geom/math.hpp index 81586461..71b559b1 100644 --- a/libs/geom/include/psemek/geom/math.hpp +++ b/libs/geom/include/psemek/geom/math.hpp @@ -60,7 +60,7 @@ namespace psemek::geom template T acos_over_sqrt_1_minus_x2(T const & x) { - auto t = std::sqrt(T{1} - x * x); + auto t = std::sqrt(std::max(T{0}, T{1} - x * x)); if (t < std::numeric_limits::epsilon()) return T{1}; return std::acos(x) / t;