From c2f4359bd742030b3a2236f3a2c828b8957e18bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 21 Feb 2013 21:18:42 +0100 Subject: [PATCH] Math: added strongly-typed asin(), acos() and atan(). --- src/Math/Functions.h | 9 +++++++++ src/Math/Test/FunctionsTest.cpp | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/Math/Functions.h b/src/Math/Functions.h index a887121a8..e1b5582e7 100644 --- a/src/Math/Functions.h +++ b/src/Math/Functions.h @@ -87,6 +87,15 @@ template inline T cos(Deg angle) { return cos(Rad(angle)); } template inline T tan(Deg angle) { return tan(Rad(angle)); } #endif +/** @brief Arc sine */ +template inline Rad asin(T value) { return Rad(std::asin(value)); } + +/** @brief Arc cosine */ +template inline Rad acos(T value) { return Rad(std::acos(value)); } + +/** @brief Arc tangent */ +template inline Rad atan(T value) { return Rad(std::atan(value)); } + /** @{ @name Scalar/vector functions diff --git a/src/Math/Test/FunctionsTest.cpp b/src/Math/Test/FunctionsTest.cpp index 70d261c66..c0d8e2809 100644 --- a/src/Math/Test/FunctionsTest.cpp +++ b/src/Math/Test/FunctionsTest.cpp @@ -251,10 +251,15 @@ void FunctionsTest::log2() { void FunctionsTest::trigonometric() { CORRADE_COMPARE(Math::sin(Deg(30.0f)), 0.5f); CORRADE_COMPARE(Math::sin(Rad(Constants::pi()/6)), 0.5f); + CORRADE_COMPARE_AS(Math::asin(0.5f), Deg(30.0f), Deg); + CORRADE_COMPARE(Math::cos(Deg(60.0f)), 0.5f); CORRADE_COMPARE(Math::cos(Rad(Constants::pi()/3)), 0.5f); + CORRADE_COMPARE_AS(Math::acos(0.5f), Deg(60.0f), Deg); + CORRADE_COMPARE(Math::tan(Deg(45.0f)), 1.0f); CORRADE_COMPARE(Math::tan(Rad(Constants::pi()/4)), 1.0f); + CORRADE_COMPARE_AS(Math::atan(1.0f), Deg(45.0f), Deg); } }}}