Browse Source

Math: added strongly-typed asin(), acos() and atan().

pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
c2f4359bd7
  1. 9
      src/Math/Functions.h
  2. 5
      src/Math/Test/FunctionsTest.cpp

9
src/Math/Functions.h

@ -87,6 +87,15 @@ template<class T> inline T cos(Deg<T> angle) { return cos(Rad<T>(angle)); }
template<class T> inline T tan(Deg<T> angle) { return tan(Rad<T>(angle)); }
#endif
/** @brief Arc sine */
template<class T> inline Rad<T> asin(T value) { return Rad<T>(std::asin(value)); }
/** @brief Arc cosine */
template<class T> inline Rad<T> acos(T value) { return Rad<T>(std::acos(value)); }
/** @brief Arc tangent */
template<class T> inline Rad<T> atan(T value) { return Rad<T>(std::atan(value)); }
/**
@{ @name Scalar/vector functions

5
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);
}
}}}

Loading…
Cancel
Save