diff --git a/include/Nazara/Math/Angle.hpp b/include/Nazara/Math/Angle.hpp index 28537473e..a64893e3a 100644 --- a/include/Nazara/Math/Angle.hpp +++ b/include/Nazara/Math/Angle.hpp @@ -53,9 +53,6 @@ namespace Nz Angle ToRadians() const; String ToString() const; - operator EulerAngles() const; - operator Quaternion() const; - Angle& operator=(const Angle&) = default; Angle operator+(const Angle& other) const; diff --git a/include/Nazara/Math/Angle.inl b/include/Nazara/Math/Angle.inl index 71d5631cc..a2a9f8c8e 100644 --- a/include/Nazara/Math/Angle.inl +++ b/include/Nazara/Math/Angle.inl @@ -319,30 +319,6 @@ namespace Nz return Detail::AngleUtils::ToString(angle); } - /*! - * \brief Shortcut allowing implicit conversion to Euler angles - * \return Euler Angles representing a 2D rotation by this angle - * - * \see ToEulerAngles - */ - template - Angle::operator EulerAngles() const - { - return ToEulerAngles(); - } - - /*! - * \brief Shortcut allowing implicit conversion to Quaternion - * \return Quaternion representing a 2D rotation by this angle - * - * \see ToQuaternion - */ - template - Angle::operator Quaternion() const - { - return ToQuaternion(); - } - /*! * \brief Converts the angle to an Euler Angles representation * \return A 2D rotation expressed in Euler angles diff --git a/include/Nazara/Math/EulerAngles.hpp b/include/Nazara/Math/EulerAngles.hpp index 126ea399e..0079d2f6a 100644 --- a/include/Nazara/Math/EulerAngles.hpp +++ b/include/Nazara/Math/EulerAngles.hpp @@ -8,6 +8,7 @@ #define NAZARA_EULERANGLES_HPP #include +#include #include #include @@ -22,6 +23,7 @@ namespace Nz EulerAngles() = default; EulerAngles(T P, T Y, T R); EulerAngles(const T angles[3]); + template EulerAngles(const Angle& angle); //EulerAngles(const Matrix3& mat); EulerAngles(const Quaternion& quat); template explicit EulerAngles(const EulerAngles& angles); @@ -34,6 +36,7 @@ namespace Nz EulerAngles& Set(T P, T Y, T R); EulerAngles& Set(const T angles[3]); + template EulerAngles& Set(const Angle& angles); EulerAngles& Set(const EulerAngles& angles); //EulerAngles& Set(const Matrix3& mat); EulerAngles& Set(const Quaternion& quat); diff --git a/include/Nazara/Math/EulerAngles.inl b/include/Nazara/Math/EulerAngles.inl index 2c35503ec..52c2e4b41 100644 --- a/include/Nazara/Math/EulerAngles.inl +++ b/include/Nazara/Math/EulerAngles.inl @@ -50,12 +50,23 @@ namespace Nz Set(angles); } + /*! + * \brief Constructs a EulerAngles object from an angle + * + * \param angle Angle representing a 2D rotation + */ + template + template + EulerAngles::EulerAngles(const Angle& angle) + { + Set(angle); + } + /*! * \brief Constructs a EulerAngles object from a quaternion * * \param quat Quaternion representing a rotation of space */ - template EulerAngles::EulerAngles(const Quaternion& quat) { @@ -142,13 +153,28 @@ namespace Nz return *this; } + + /*! + * \brief Sets the components of the euler angle from a 2D rotation specified by an Angle + * \return A reference to this euler angle + * + * \param angle 2D angle + * + * \see Angle + */ + template + template + EulerAngles& EulerAngles::Set(const Angle& angle) + { + return Set(angle.ToEulerAngles()); + } + /*! * \brief Sets the components of the euler angle from another euler angle * \return A reference to this euler angle * * \param angles The other euler angle */ - template EulerAngles& EulerAngles::Set(const EulerAngles& angles) { @@ -394,3 +420,4 @@ std::ostream& operator<<(std::ostream& out, const Nz::EulerAngles& angles) #undef F #include +#include "EulerAngles.hpp" diff --git a/include/Nazara/Math/Quaternion.hpp b/include/Nazara/Math/Quaternion.hpp index 17c9a8757..16e88b8ef 100644 --- a/include/Nazara/Math/Quaternion.hpp +++ b/include/Nazara/Math/Quaternion.hpp @@ -8,6 +8,7 @@ #define NAZARA_QUATERNION_HPP #include +#include namespace Nz { @@ -21,6 +22,7 @@ namespace Nz public: Quaternion() = default; Quaternion(T W, T X, T Y, T Z); + template Quaternion(const Angle& angle); Quaternion(const EulerAngles& angles); Quaternion(T angle, const Vector3& axis); Quaternion(const T quat[4]); @@ -49,6 +51,7 @@ namespace Nz Quaternion& Normalize(T* length = nullptr); Quaternion& Set(T W, T X, T Y, T Z); + template Quaternion& Set(const Angle& angle); Quaternion& Set(const EulerAngles& angles); Quaternion& Set(T angle, const Vector3& normalizedAxis); Quaternion& Set(const T quat[4]); diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index 59099f3b8..f253d7d6b 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -39,6 +39,18 @@ namespace Nz Set(W, X, Y, Z); } + /*! + * \brief Constructs a Quaternion object from an angle + * + * \param angle Angle representing a 2D rotation + */ + template + template + Quaternion::Quaternion(const Angle& angle) + { + Set(angle); + } + /*! * \brief Constructs a Quaternion object from a EulerAngles * @@ -46,7 +58,6 @@ namespace Nz * * \see EulerAngles */ - template Quaternion::Quaternion(const EulerAngles& angles) { @@ -343,6 +354,21 @@ namespace Nz return *this; } + /*! + * \brief Sets this quaternion from a 2D rotation specified by an Angle + * \return A reference to this quaternion + * + * \param angle 2D angle + * + * \see Angle + */ + template + template + Quaternion& Quaternion::Set(const Angle& angle) + { + return Set(angle.ToQuaternion()); + } + /*! * \brief Sets this quaternion from rotation specified by Euler angle * \return A reference to this quaternion @@ -351,7 +377,6 @@ namespace Nz * * \see EulerAngles */ - template Quaternion& Quaternion::Set(const EulerAngles& angles) { @@ -886,3 +911,4 @@ std::ostream& operator<<(std::ostream& out, const Nz::Quaternion& quat) #undef F #include +#include "Quaternion.hpp"