diff --git a/libs/geom/include/psemek/geom/math.hpp b/libs/geom/include/psemek/geom/math.hpp index 61f91c44..81586461 100644 --- a/libs/geom/include/psemek/geom/math.hpp +++ b/libs/geom/include/psemek/geom/math.hpp @@ -57,6 +57,15 @@ namespace psemek::geom return std::sin(x) / x; } + template + T acos_over_sqrt_1_minus_x2(T const & x) + { + auto t = std::sqrt(T{1} - x * x); + if (t < std::numeric_limits::epsilon()) + return T{1}; + return std::acos(x) / t; + } + namespace detail {