diff --git a/src/Math/Math.h b/src/Math/Math.h index cfd22d08a..4f6d641a2 100644 --- a/src/Math/Math.h +++ b/src/Math/Math.h @@ -50,14 +50,14 @@ template struct Constants { #ifndef DOXYGEN_GENERATING_OUTPUT template<> struct Constants { - static inline constexpr double pi() { return 3.14159265359; } - static inline constexpr double sqrt2() { return 1.41421356237; } - static inline constexpr double sqrt3() { return 1.73205080757; } + static inline constexpr double pi() { return 3.141592653589793; } + static inline constexpr double sqrt2() { return 1.414213562373095; } + static inline constexpr double sqrt3() { return 1.732050807568877; } }; template<> struct Constants { - static inline constexpr float pi() { return 3.14159265359f; } - static inline constexpr float sqrt2() { return 1.41421356237f; } - static inline constexpr float sqrt3() { return 1.73205080757f; } + static inline constexpr float pi() { return 3.141592654f; } + static inline constexpr float sqrt2() { return 1.414213562f; } + static inline constexpr float sqrt3() { return 1.732050808f; } }; namespace Implementation { diff --git a/src/Math/Test/MathTest.cpp b/src/Math/Test/MathTest.cpp index db4d29676..9d76e9535 100644 --- a/src/Math/Test/MathTest.cpp +++ b/src/Math/Test/MathTest.cpp @@ -24,13 +24,22 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::MathTest) namespace Magnum { namespace Math { namespace Test { MathTest::MathTest() { - addTests(&MathTest::degrad, + addTests(&MathTest::constants, + &MathTest::degrad, &MathTest::normalize, &MathTest::denormalize, &MathTest::pow, &MathTest::log); } +void MathTest::constants() { + CORRADE_COMPARE(Math::pow<2>(Constants::sqrt2()), 2.0f); + CORRADE_COMPARE(Math::pow<2>(Constants::sqrt3()), 3.0f); + + CORRADE_COMPARE(Math::pow<2>(Constants::sqrt2()), 2.0); + CORRADE_COMPARE(Math::pow<2>(Constants::sqrt3()), 3.0); +} + void MathTest::degrad() { CORRADE_COMPARE(deg(90.0), Constants::pi()/2); CORRADE_COMPARE(deg(90.0f), Constants::pi()/2); diff --git a/src/Math/Test/MathTest.h b/src/Math/Test/MathTest.h index b6dcba0c8..3bb32c5ea 100644 --- a/src/Math/Test/MathTest.h +++ b/src/Math/Test/MathTest.h @@ -23,6 +23,7 @@ class MathTest: public Corrade::TestSuite::Tester { public: MathTest(); + void constants(); void degrad(); void normalize(); void denormalize();