Browse Source

Math: removed old deg()/rad() helpers.

pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
3ccc6a794e
  1. 6
      src/Magnum.h
  2. 27
      src/Math/Constants.h
  3. 10
      src/Math/Test/ConstantsTest.cpp

6
src/Magnum.h

@ -51,8 +51,6 @@ namespace Magnum {
/** @todoc Remove `ifndef` when Doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
namespace Math {
template<class T> constexpr T deg(T value);
template<class T> constexpr T rad(T value);
template<class T> struct Constants;
constexpr Rad<double> operator "" _rad(long double);
@ -125,10 +123,6 @@ typedef Math::Geometry::Rectangle<GLfloat> Rectangle;
/** @brief Integer rectangle */
typedef Math::Geometry::Rectangle<GLint> Rectanglei;
/* Copying angle converters from Math namespace */
using Math::deg;
using Math::rad;
/* Using angle literals from Math namespace */
using Math::operator "" _deg;
using Math::operator "" _degf;

27
src/Math/Constants.h

@ -16,7 +16,7 @@
*/
/** @file
* @brief Class Magnum::Math::Constants, functions Magnum::Math::deg(), Magnum::Math::rad()
* @brief Class Magnum::Math::Constants
*/
namespace Magnum { namespace Math {
@ -34,7 +34,7 @@ template<class T> struct Constants {
/**
* @brief Pi
*
* @see deg(), rad()
* @see Deg, Rad
*/
static inline constexpr T pi();
@ -60,29 +60,6 @@ template<> struct Constants<float> {
};
#endif
/**
@brief Angle in degrees
Function to make angle entering less error-prone. Converts the value to
radians at compile time. For example `deg(180.0f)` is converted to `3.14f`.
Usable for entering e.g. rotation:
@code
Matrix4::rotation(deg(30.0f), Vector3::yAxis());
@endcode
@see Magnum::deg(), Constants, rad()
*/
template<class T> inline constexpr T deg(T value) { return value*Constants<T>::pi()/180; }
/**
@brief Angle in radians
See deg() for more information.
@see Magnum::rad()
*/
template<class T> inline constexpr T rad(T value) { return value; }
}}
#endif

10
src/Math/Test/ConstantsTest.cpp

@ -25,12 +25,10 @@ class ConstantsTest: public Corrade::TestSuite::Tester {
ConstantsTest();
void constants();
void degrad();
};
ConstantsTest::ConstantsTest() {
addTests(&ConstantsTest::constants,
&ConstantsTest::degrad);
addTests(&ConstantsTest::constants);
}
void ConstantsTest::constants() {
@ -41,12 +39,6 @@ void ConstantsTest::constants() {
CORRADE_COMPARE(Math::pow<2>(Constants<double>::sqrt3()), 3.0);
}
void ConstantsTest::degrad() {
CORRADE_COMPARE(deg(90.0), Constants<double>::pi()/2);
CORRADE_COMPARE(deg(90.0f), Constants<float>::pi()/2);
CORRADE_COMPARE(rad(Constants<double>::pi()/2), Constants<double>::pi()/2);
}
}}}
CORRADE_TEST_MAIN(Magnum::Math::Test::ConstantsTest)

Loading…
Cancel
Save