Fix geom::acos_over_sqrt_1_minus_x2 to allow arguments slightly larger than 1 to prevent NaNs
This commit is contained in:
parent
efc22a5bd7
commit
7babed1c57
1 changed files with 1 additions and 1 deletions
|
|
@ -60,7 +60,7 @@ namespace psemek::geom
|
|||
template <typename T>
|
||||
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<T>::epsilon())
|
||||
return T{1};
|
||||
return std::acos(x) / t;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue