Browse Source

Brought Math::Deg/Rad and related operators to Magnum namespace.

pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
a3924c9176
  1. 17
      src/Magnum.h
  2. 11
      src/Math/Angle.h

17
src/Magnum.h

@ -54,6 +54,11 @@ 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);
constexpr Rad<float> operator "" _radf(long double);
constexpr Deg<double> operator "" _deg(long double);
constexpr Deg<float> operator "" _degf(long double);
}
/* Bring debugging facility from Corrade::Utility namespace */
@ -108,6 +113,12 @@ typedef Math::Quaternion<GLfloat> Quaternion;
/* Using float instead of GLfloat to not break KDevelop autocompletion */
typedef Math::Constants<float> Constants;
/** @brief Angle in single-precision degrees */
typedef Math::Deg<float> Deg;
/** @brief Angle in single-precision radians */
typedef Math::Rad<float> Rad;
/** @brief Floating-point rectangle */
typedef Math::Geometry::Rectangle<GLfloat> Rectangle;
@ -118,6 +129,12 @@ typedef Math::Geometry::Rectangle<GLint> Rectanglei;
using Math::deg;
using Math::rad;
/* Using angle literals from Math namespace */
using Math::operator "" _deg;
using Math::operator "" _degf;
using Math::operator "" _rad;
using Math::operator "" _radf;
/** @todoc Remove `ifndef` when Doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
/* Forward declarations for all types in root namespace */

11
src/Math/Angle.h

@ -108,6 +108,8 @@ std::sin(float(Rad<float>(angleInDegrees)); // required explicit conversion hint
// to user that this case needs special
// attention (i.e., conversion to radians)
@endcode
@see Magnum::Deg, Magnum::Rad
*/
template<class T> class Deg: public Unit<Deg, T> {
public:
@ -143,7 +145,7 @@ Example usage:
double cosine = Math::cos(60.0_deg); // cosine = 0.5
double cosine = Math::cos(1.047_rad); // cosine = 0.5
@endcode
@see operator""_degf(), operator""_rad()
@see Magnum::operator""_deg(), operator""_degf(), operator""_rad()
@note Not available on GCC < 4.7. Use Deg::Deg(T) instead.
*/
inline constexpr Deg<double> operator "" _deg(long double value) { return Deg<double>(value); }
@ -156,7 +158,7 @@ Example usage:
float tangent = Math::tan(60.0_degf); // tangent = 1.732f
float tangent = Math::tan(1.047_radf); // tangent = 1.732f
@endcode
@see operator""_deg(), operator""_radf()
@see Magnum::operator""_degf(), operator""_deg(), operator""_radf()
@note Not available on GCC < 4.7. Use Deg::Deg(T) instead.
*/
inline constexpr Deg<float> operator "" _degf(long double value) { return Deg<float>(value); }
@ -166,6 +168,7 @@ inline constexpr Deg<float> operator "" _degf(long double value) { return Deg<fl
@brief Angle in radians
See Deg for more information.
@see Magnum::Rad
*/
template<class T> class Rad: public Unit<Rad, T> {
public:
@ -197,7 +200,7 @@ template<class T> class Rad: public Unit<Rad, T> {
@brief Double-precision radian value literal
See operator""_rad() for more information.
@see operator""_radf(), operator""_deg()
@see Magnum::operator""_rad(), operator""_radf(), operator""_deg()
@note Not available on GCC < 4.7. Use Rad::Rad(T) instead.
*/
inline constexpr Rad<double> operator "" _rad(long double value) { return Rad<double>(value); }
@ -206,7 +209,7 @@ inline constexpr Rad<double> operator "" _rad(long double value) { return Rad<do
@brief Single-precision radian value literal
See operator""_degf() for more information.
@see operator""_rad(), operator""_degf()
@see Magnum::operator""_radf(), operator""_rad(), operator""_degf()
@note Not available on GCC < 4.7. Use Rad::Rad(T) instead.
*/
inline constexpr Rad<float> operator "" _radf(long double value) { return Rad<float>(value); }

Loading…
Cancel
Save