diff --git a/src/math.cpp b/src/math.cpp index af41dd2..6ebf754 100644 --- a/src/math.cpp +++ b/src/math.cpp @@ -125,7 +125,7 @@ namespace bx const float tmp5 = tmp4 * mxy; const float tmp6 = ay > ax ? kPiHalf - tmp5 : tmp5; const float tmp7 = _x < 0.0f ? kPi - tmp6 : tmp6; - const float result = sign(_y)*tmp7; + const float result = (_y < 0.0f ? -1.0f : 1.0f)*tmp7; return result; } diff --git a/tests/math_test.cpp b/tests/math_test.cpp index ebe73e2..a4c3544 100644 --- a/tests/math_test.cpp +++ b/tests/math_test.cpp @@ -63,6 +63,7 @@ TEST_CASE("log2", "") TEST_CASE("libm", "") { bx::WriterI* writer = bx::getNullOut(); + bx::Error err; REQUIRE(1389.0f == bx::abs(-1389.0f) ); REQUIRE(1389.0f == bx::abs( 1389.0f) ); @@ -81,8 +82,6 @@ TEST_CASE("libm", "") REQUIRE(bx::isEqual( 0.89f, bx::fract( 13.89f), 0.000001f) ); REQUIRE(bx::isEqual(-0.89f, bx::fract(-13.89f), 0.000001f) ); - bx::Error err; - for (int32_t yy = -10; yy < 10; ++yy) { for (float xx = -100.0f; xx < 100.0f; xx += 0.1f) @@ -196,6 +195,16 @@ TEST_CASE("libm", "") REQUIRE(err.isOk() ); REQUIRE(bx::isEqual(bx::atan(xx), ::atanf(xx), 0.00001f) ); } +} + +TEST_CASE("atan2", "") +{ + bx::WriterI* writer = bx::getNullOut(); + bx::Error err; + + REQUIRE(bx::isEqual(bx::atan2(0.0f, 0.0f), ::atan2f(0.0f, 0.0f), 0.00001f) ); + REQUIRE(bx::isEqual(bx::atan2(0.0f, 1.0f), ::atan2f(0.0f, 1.0f), 0.00001f) ); + REQUIRE(bx::isEqual(bx::atan2(0.0f, -1.0f), ::atan2f(0.0f, -1.0f), 0.00001f) ); for (float yy = -100.0f; yy < 100.0f; yy += 0.1f) { @@ -206,8 +215,6 @@ TEST_CASE("libm", "") REQUIRE(bx::isEqual(bx::atan2(yy, xx), ::atan2f(yy, xx), 0.00001f) ); } } - - REQUIRE(bx::isEqual(bx::atan2(0.0f, 0.0f), ::atan2f(0.0f, 0.0f), 0.00001f) ); } TEST_CASE("sign", "")