mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
fix math functions
This commit is contained in:
parent
2e2b6c96ab
commit
ffb876c930
23 changed files with 85 additions and 37 deletions
|
@ -7,6 +7,8 @@
|
|||
#include <sprout/math/detail/config.hpp>
|
||||
#include <sprout/math/detail/float_compute.hpp>
|
||||
#include <sprout/math/constants.hpp>
|
||||
#include <sprout/math/isnan.hpp>
|
||||
#include <sprout/math/signbit.hpp>
|
||||
#include <sprout/math/copysign.hpp>
|
||||
#include <sprout/math/signbit.hpp>
|
||||
#include <sprout/math/atan.hpp>
|
||||
|
@ -33,7 +35,13 @@ namespace sprout {
|
|||
>
|
||||
inline SPROUT_CONSTEXPR FloatType
|
||||
atan2(FloatType y, FloatType x) {
|
||||
return x == -std::numeric_limits<FloatType>::infinity()
|
||||
return sprout::math::isnan(y)
|
||||
? sprout::math::isnan(x)
|
||||
? sprout::math::signbit(y) && sprout::math::signbit(x) ? -std::numeric_limits<double>::quiet_NaN()
|
||||
: std::numeric_limits<double>::quiet_NaN()
|
||||
: y
|
||||
: sprout::math::isnan(x) ? x
|
||||
: x == -std::numeric_limits<FloatType>::infinity()
|
||||
? y == std::numeric_limits<FloatType>::infinity() ? sprout::math::three_quarters_pi<FloatType>()
|
||||
: y == -std::numeric_limits<FloatType>::infinity() ? -sprout::math::three_quarters_pi<FloatType>()
|
||||
: sprout::math::copysign(sprout::math::pi<FloatType>(), y)
|
||||
|
@ -77,11 +85,14 @@ namespace sprout {
|
|||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// bug:
|
||||
// issue:
|
||||
// [ !SPROUT_USE_BUILTIN_CMATH_FUNCTION ]
|
||||
// atan2(<28>}0, -0) returns <20>}ƒÎ .
|
||||
// # returns <20>}0 . ( same as atan2(<28>}0, +0) )
|
||||
// atan2(-0, x) returns -ƒÎ for x < 0.
|
||||
// # returns +ƒÎ . ( same as atan2(+0, x) )
|
||||
// atan2(-NaN, -NaN) returns -NaN .
|
||||
// # returns +NaN . ( same as atan2(+NaN, +NaN) )
|
||||
//
|
||||
using sprout::math::detail::atan2;
|
||||
} // namespace math
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue