diff --git a/src/Magnum.h b/src/Magnum.h index 440d57a67..2fb91a908 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -54,6 +54,11 @@ namespace Math { template constexpr T deg(T value); template constexpr T rad(T value); template struct Constants; + + constexpr Rad operator "" _rad(long double); + constexpr Rad operator "" _radf(long double); + constexpr Deg operator "" _deg(long double); + constexpr Deg operator "" _degf(long double); } /* Bring debugging facility from Corrade::Utility namespace */ @@ -108,6 +113,12 @@ typedef Math::Quaternion Quaternion; /* Using float instead of GLfloat to not break KDevelop autocompletion */ typedef Math::Constants Constants; +/** @brief Angle in single-precision degrees */ +typedef Math::Deg Deg; + +/** @brief Angle in single-precision radians */ +typedef Math::Rad Rad; + /** @brief Floating-point rectangle */ typedef Math::Geometry::Rectangle Rectangle; @@ -118,6 +129,12 @@ typedef Math::Geometry::Rectangle 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 */ diff --git a/src/Math/Angle.h b/src/Math/Angle.h index d579c1b39..c1b136b8c 100644 --- a/src/Math/Angle.h +++ b/src/Math/Angle.h @@ -108,6 +108,8 @@ std::sin(float(Rad(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 Deg: public Unit { 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 operator "" _deg(long double value) { return Deg(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 operator "" _degf(long double value) { return Deg(value); } @@ -166,6 +168,7 @@ inline constexpr Deg operator "" _degf(long double value) { return Deg class Rad: public Unit { public: @@ -197,7 +200,7 @@ template class Rad: public Unit { @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 operator "" _rad(long double value) { return Rad(value); } @@ -206,7 +209,7 @@ inline constexpr Rad operator "" _rad(long double value) { return Rad operator "" _radf(long double value) { return Rad(value); }