Add stable implementation of acos(x)/sqrt(1-x*x)

This commit is contained in:
Nikita Lisitsa 2022-01-10 17:45:43 +03:00
parent 23551f681d
commit efc22a5bd7

View file

@ -57,6 +57,15 @@ namespace psemek::geom
return std::sin(x) / x;
}
template <typename T>
T acos_over_sqrt_1_minus_x2(T const & x)
{
auto t = std::sqrt(T{1} - x * x);
if (t < std::numeric_limits<T>::epsilon())
return T{1};
return std::acos(x) / t;
}
namespace detail
{