Add stable implementation of acos(x)/sqrt(1-x*x)
This commit is contained in:
parent
23551f681d
commit
efc22a5bd7
1 changed files with 9 additions and 0 deletions
|
|
@ -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
|
||||
{
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue