1
0
Fork 0
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:
bolero-MURAKAMI 2013-04-26 00:25:35 +09:00
parent dad3acceea
commit 2e2b6c96ab
30 changed files with 121 additions and 84 deletions

View file

@ -40,7 +40,7 @@ namespace sprout {
: x == std::numeric_limits<FloatType>::infinity()
? y == std::numeric_limits<FloatType>::infinity() ? sprout::math::quarter_pi<FloatType>()
: y == -std::numeric_limits<FloatType>::infinity() ? -sprout::math::quarter_pi<FloatType>()
: sprout::math::copysign(FloatType(0), y)
: FloatType(0) * y
: y == std::numeric_limits<FloatType>::infinity() ? sprout::math::half_pi<FloatType>()
: y == -std::numeric_limits<FloatType>::infinity() ? -sprout::math::half_pi<FloatType>()
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
@ -48,9 +48,9 @@ namespace sprout {
#else
: y == 0
? x < 0 ? sprout::math::copysign(sprout::math::pi<FloatType>(), y)
: x > 0 ? sprout::math::copysign(FloatType(0), y)
: x > 0 ? FloatType(0) * y
: sprout::math::signbit(x) ? sprout::math::copysign(sprout::math::pi<FloatType>(), y)
: sprout::math::copysign(FloatType(0), y)
: FloatType(0) * y
: x == 0
? y < 0 ? -sprout::math::half_pi<FloatType>()
: sprout::math::half_pi<FloatType>()
@ -76,7 +76,13 @@ namespace sprout {
return sprout::math::detail::atan2(static_cast<type>(y), static_cast<type>(x));
}
} // namespace detail
//
// bug:
// 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) )
//
using sprout::math::detail::atan2;
} // namespace math