Math/Angle: Replace conversion constructors by conversion operators
This commit is contained in:
parent
6653be6f2c
commit
d2b1d51ecb
|
|
@ -27,8 +27,6 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
Angle() = default;
|
Angle() = default;
|
||||||
Angle(T value);
|
Angle(T value);
|
||||||
template<AngleUnit U = Unit, typename = std::enable_if_t<U == AngleUnit::Degree>> explicit Angle(const Angle<AngleUnit::Radian, T>& value) { Set(value); }
|
|
||||||
template<AngleUnit U = Unit, typename = std::enable_if_t<U == AngleUnit::Radian>> explicit Angle(const Angle<AngleUnit::Degree, T>& value) { Set(value); }
|
|
||||||
template<typename U> explicit Angle(const Angle<Unit, U>& Angle);
|
template<typename U> explicit Angle(const Angle<Unit, U>& Angle);
|
||||||
Angle(const Angle&) = default;
|
Angle(const Angle&) = default;
|
||||||
~Angle() = default;
|
~Angle() = default;
|
||||||
|
|
@ -42,8 +40,6 @@ namespace Nz
|
||||||
|
|
||||||
void Normalize();
|
void Normalize();
|
||||||
|
|
||||||
template<AngleUnit U = Unit, typename = std::enable_if_t<U == AngleUnit::Degree>> Angle& Set(const Angle<AngleUnit::Radian, T>& ang);
|
|
||||||
template<AngleUnit U = Unit, typename = std::enable_if_t<U == AngleUnit::Radian>> Angle& Set(const Angle<AngleUnit::Degree, T>& ang);
|
|
||||||
Angle& Set(const Angle& ang);
|
Angle& Set(const Angle& ang);
|
||||||
template<typename U> Angle& Set(const Angle<Unit, U>& ang);
|
template<typename U> Angle& Set(const Angle<Unit, U>& ang);
|
||||||
|
|
||||||
|
|
@ -55,6 +51,9 @@ namespace Nz
|
||||||
Angle<AngleUnit::Radian, T> ToRadianAngle() const;
|
Angle<AngleUnit::Radian, T> ToRadianAngle() const;
|
||||||
String ToString() const;
|
String ToString() const;
|
||||||
|
|
||||||
|
template<AngleUnit U = Unit, typename = std::enable_if_t<U != AngleUnit::Degree>> operator Angle<AngleUnit::Degree, T>();
|
||||||
|
template<AngleUnit U = Unit, typename = std::enable_if_t<U != AngleUnit::Radian>> operator Angle<AngleUnit::Radian, T>();
|
||||||
|
|
||||||
Angle& operator=(const Angle&) = default;
|
Angle& operator=(const Angle&) = default;
|
||||||
|
|
||||||
Angle operator+(const Angle& other) const;
|
Angle operator+(const Angle& other) const;
|
||||||
|
|
|
||||||
|
|
@ -236,32 +236,6 @@ namespace Nz
|
||||||
value += twoLimit;
|
value += twoLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Changes the angle value by converting a radian angle
|
|
||||||
*
|
|
||||||
* \param Angle Radian angle which will be converted
|
|
||||||
*/
|
|
||||||
template<AngleUnit Unit, typename T>
|
|
||||||
template<AngleUnit U, typename>
|
|
||||||
Angle<Unit, T>& Angle<Unit, T>::Set(const Angle<AngleUnit::Radian, T>& ang)
|
|
||||||
{
|
|
||||||
value = RadianToDegree(ang.value);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Changes the angle value by converting a degree angle
|
|
||||||
*
|
|
||||||
* \param Angle Degree angle which will be converted
|
|
||||||
*/
|
|
||||||
template<AngleUnit Unit, typename T>
|
|
||||||
template<AngleUnit U, typename>
|
|
||||||
Angle<Unit, T>& Angle<Unit, T>::Set(const Angle<AngleUnit::Degree, T>& ang)
|
|
||||||
{
|
|
||||||
value = DegreeToRadian(ang.value);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Copies the angle value of an angle
|
* \brief Copies the angle value of an angle
|
||||||
*
|
*
|
||||||
|
|
@ -367,6 +341,28 @@ namespace Nz
|
||||||
return Detail::AngleUtils<Unit>::ToString(value);
|
return Detail::AngleUtils<Unit>::ToString(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the degree angle that is equivalent to this one
|
||||||
|
* \return Equivalent degree angle
|
||||||
|
*/
|
||||||
|
template<AngleUnit Unit, typename T>
|
||||||
|
template<AngleUnit U, typename>
|
||||||
|
Angle<Unit, T>::operator Angle<AngleUnit::Degree, T>()
|
||||||
|
{
|
||||||
|
return ToDegreeAngle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Converts the angle to a string representation
|
||||||
|
* \return String representation of the angle
|
||||||
|
*/
|
||||||
|
template<AngleUnit Unit, typename T>
|
||||||
|
template<AngleUnit U, typename>
|
||||||
|
Angle<Unit, T>::operator Angle<AngleUnit::Radian, T>()
|
||||||
|
{
|
||||||
|
return ToRadianAngle();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Addition operator
|
* \brief Addition operator
|
||||||
* \return Adds two angles together
|
* \return Adds two angles together
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue