diff --git a/examples/DeferredShading/main.cpp b/examples/DeferredShading/main.cpp index 4f4f6af90..20525cd4f 100644 --- a/examples/DeferredShading/main.cpp +++ b/examples/DeferredShading/main.cpp @@ -214,7 +214,7 @@ int main() Nz::Vector2ui windowSize = window.GetSize(); Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.viewMatrixOffset) = Nz::Matrix4f::Translate(Nz::Vector3f::Backward() * 1); - Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.projMatrixOffset) = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 0.1f, 1000.f); + Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.projMatrixOffset) = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f); Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.invTargetSizeOffset) = 1.f / Nz::Vector2f(window.GetSize().x, window.GetSize().y); std::vector instanceDataBuffer(instanceUboOffsets.totalSize); @@ -770,7 +770,8 @@ int main() float sensitivity = 0.3f; // Sensibilité de la souris // On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris - camAngles.yaw = Nz::NormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity); + camAngles.yaw = camAngles.yaw - event.mouseMove.deltaX*sensitivity; + camAngles.yaw.Normalize(); // Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles camAngles.pitch = Nz::Clamp(camAngles.pitch + event.mouseMove.deltaY*sensitivity, -89.f, 89.f); @@ -802,7 +803,7 @@ int main() case Nz::WindowEventType::Resized: { Nz::Vector2ui windowSize = window.GetSize(); - Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.projMatrixOffset) = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 0.1f, 1000.f); + Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.projMatrixOffset) = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f); viewerUboUpdate = true; break; } diff --git a/examples/GraphicsTest/main.cpp b/examples/GraphicsTest/main.cpp index 6960a0b75..cbdee4428 100644 --- a/examples/GraphicsTest/main.cpp +++ b/examples/GraphicsTest/main.cpp @@ -83,7 +83,7 @@ int main() Nz::Vector2ui windowSize = window.GetSize(); Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.viewMatrixOffset) = Nz::Matrix4f::Translate(Nz::Vector3f::Backward() * 1); - Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.projMatrixOffset) = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 0.1f, 1000.f); + Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.projMatrixOffset) = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f); std::vector instanceDataBuffer(instanceUboOffsets.totalSize); @@ -186,7 +186,8 @@ int main() float sensitivity = 0.3f; // Sensibilité de la souris // On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris - camAngles.yaw = Nz::NormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity); + camAngles.yaw = camAngles.yaw - event.mouseMove.deltaX * sensitivity; + camAngles.yaw.Normalize(); // Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles camAngles.pitch = Nz::Clamp(camAngles.pitch + event.mouseMove.deltaY*sensitivity, -89.f, 89.f); @@ -200,7 +201,7 @@ int main() case Nz::WindowEventType::Resized: { Nz::Vector2ui windowSize = window.GetSize(); - Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.projMatrixOffset) = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 0.1f, 1000.f); + Nz::AccessByOffset(viewerDataBuffer.data(), viewerUboOffsets.projMatrixOffset) = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f); viewerUboUpdate = true; break; } diff --git a/examples/RenderTest/main.cpp b/examples/RenderTest/main.cpp index 86f8f610d..c0a82dc26 100644 --- a/examples/RenderTest/main.cpp +++ b/examples/RenderTest/main.cpp @@ -145,7 +145,7 @@ int main() ubo; Nz::Vector2ui windowSize = window.GetSize(); - ubo.projectionMatrix = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 0.1f, 1000.f); + ubo.projectionMatrix = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f); ubo.viewMatrix = Nz::Matrix4f::Translate(Nz::Vector3f::Backward() * 1); ubo.modelMatrix = Nz::Matrix4f::Translate(Nz::Vector3f::Forward() * 2 + Nz::Vector3f::Right()); @@ -291,7 +291,8 @@ int main() float sensitivity = 0.3f; // Sensibilité de la souris // On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris - camAngles.yaw = Nz::NormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity); + camAngles.yaw = camAngles.yaw - event.mouseMove.deltaX * sensitivity; + camAngles.yaw.Normalize(); // Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles camAngles.pitch = Nz::Clamp(camAngles.pitch + event.mouseMove.deltaY*sensitivity, -89.f, 89.f); @@ -305,7 +306,7 @@ int main() case Nz::WindowEventType::Resized: { Nz::Vector2ui windowSize = window.GetSize(); - ubo.projectionMatrix = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 0.1f, 1000.f); + ubo.projectionMatrix = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f); uboUpdate = true; break; } diff --git a/include/Nazara/Math/Algorithm.hpp b/include/Nazara/Math/Algorithm.hpp index 5109c68d5..4c07bfb96 100644 --- a/include/Nazara/Math/Algorithm.hpp +++ b/include/Nazara/Math/Algorithm.hpp @@ -9,6 +9,7 @@ #define NAZARA_ALGORITHM_MATH_HPP #include +#include #include #include #include @@ -35,11 +36,12 @@ namespace Nz { + template class Angle; + template constexpr T Approach(T value, T objective, T increment); template constexpr T Clamp(T value, T min, T max); + template constexpr Angle Clamp(Angle value, T min, T max); template constexpr std::size_t CountBits(T value); - template constexpr T FromDegrees(T degrees); - template constexpr T FromRadians(T radians); template constexpr T DegreeToRadian(T degrees); template constexpr T GetNearestPowerOfTwo(T number); constexpr unsigned int GetNumberLength(signed char number); @@ -56,7 +58,6 @@ namespace Nz template constexpr T IntegralPow(T base, unsigned int exponent); template constexpr T Lerp(const T& from, const T& to, const T2& interpolation); template constexpr T MultiplyAdd(T x, T y, T z); - template constexpr T NormalizeAngle(T angle); template constexpr bool NumberEquals(T a, T b); template constexpr bool NumberEquals(T a, T b, T maxDifference); inline std::string NumberToString(long long number, UInt8 radix = 10); @@ -64,8 +65,6 @@ namespace Nz template T SetBit(T number, T bit); inline long long StringToNumber(const std::string_view& str, UInt8 radix = 10, bool* ok = nullptr); template bool TestBit(T number, T bit); - template constexpr T ToDegrees(T angle); - template constexpr T ToRadians(T angle); } #include diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index f5ef47381..a26d33d2e 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -157,6 +157,21 @@ namespace Nz return std::max(std::min(value, max), min); } + /*! + * \ingroup math + * \brief Clamps an angle value between min and max and returns the expected value + * \return If value is not in the interval of min..max, value obtained is the nearest limit of this interval + * + * \param value Value to clamp + * \param min Minimum of the interval + * \param max Maximum of the interval + */ + template + constexpr Angle Clamp(Angle value, T min, T max) + { + return T(); + } + /*! * \ingroup math * \brief Gets number of bits set in the number @@ -191,40 +206,6 @@ namespace Nz return degrees * T(M_PI/180.0); } - /*! - * \ingroup math - * \brief Gets the unit from degree and convert it according to NAZARA_MATH_ANGLE_RADIAN - * \return Express the degrees - * - * \param degrees Convert degree to NAZARA_MATH_ANGLE_RADIAN unit - */ - template - constexpr T FromDegrees(T degrees) - { - #if NAZARA_MATH_ANGLE_RADIAN - return DegreeToRadian(degrees); - #else - return degrees; - #endif - } - - /*! - * \ingroup math - * \brief Gets the unit from radian and convert it according to NAZARA_MATH_ANGLE_RADIAN - * \return Express the radians - * - * \param radians Convert radian to NAZARA_MATH_ANGLE_RADIAN unit - */ - template - constexpr T FromRadians(T radians) - { - #if NAZARA_MATH_ANGLE_RADIAN - return radians; - #else - return RadianToDegree(radians); - #endif - } - /*! * \ingroup math * \brief Gets the nearest power of two for the number @@ -506,30 +487,6 @@ namespace Nz } #endif - /*! - * \ingroup math - * \brief Normalizes the angle - * \return Normalized value between 0..2*(pi if radian or 180 if degrees) - * - * \param angle Angle to normalize - */ - template - constexpr inline T NormalizeAngle(T angle) - { - #if NAZARA_MATH_ANGLE_RADIAN - const T limit = T(M_PI); - #else - const T limit = T(180.0); - #endif - const T twoLimit = limit * T(2); - - angle = std::fmod(angle, twoLimit); - if (angle < T(0)) - angle += twoLimit; - - return angle; - } - /*! * \ingroup math * \brief Checks whether two numbers are equal @@ -702,40 +659,7 @@ namespace Nz NazaraAssert(bit < sizeof(number) * CHAR_BIT, "bit index out of range"); return number & (T(1) << bit); } - - /*! - * \ingroup math - * \brief Gets the degree from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN - * \return Express in degrees - * - * \param angle Convert degree from NAZARA_MATH_ANGLE_RADIAN unit to degrees - */ - template - constexpr T ToDegrees(T angle) - { - #if NAZARA_MATH_ANGLE_RADIAN - return RadianToDegree(angle); - #else - return angle; - #endif - } - - /*! - * \ingroup math - * \brief Gets the radian from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN - * \return Express in radians - * - * \param angle Convert degree from NAZARA_MATH_ANGLE_RADIAN unit to radians - */ - template - constexpr T ToRadians(T angle) - { - #if NAZARA_MATH_ANGLE_RADIAN - return angle; - #else - return DegreeToRadian(angle); - #endif - } } #include +#include "Algorithm.hpp" diff --git a/include/Nazara/Math/Angle.hpp b/include/Nazara/Math/Angle.hpp index 46c1d30ab..c59f629ab 100644 --- a/include/Nazara/Math/Angle.hpp +++ b/include/Nazara/Math/Angle.hpp @@ -26,11 +26,11 @@ namespace Nz class Angle { public: - Angle() = default; - Angle(T angle); - Angle(const Angle& angle); - Angle(const Angle& angle); - template explicit Angle(const Angle& Angle); + constexpr Angle() = default; + constexpr Angle(T angle); + template constexpr explicit Angle(const Angle& Angle); + constexpr Angle(const Angle& angle); + constexpr Angle(const Angle& angle); ~Angle() = default; T GetCos() const; @@ -38,39 +38,39 @@ namespace Nz std::pair GetSinCos() const; T GetTan() const; - Angle& MakeZero(); + constexpr Angle& MakeZero(); - void Normalize(); + constexpr Angle& Normalize(); - Angle& Set(const Angle& ang); - template Angle& Set(const Angle& ang); + constexpr Angle& Set(const Angle& ang); + template constexpr Angle& Set(const Angle& ang); - T ToDegrees() const; - Angle ToDegreeAngle() const; + constexpr T ToDegrees() const; + constexpr Angle ToDegreeAngle() const; EulerAngles ToEulerAngles() const; Quaternion ToQuaternion() const; - T ToRadians() const; - Angle ToRadianAngle() const; + constexpr T ToRadians() const; + constexpr Angle ToRadianAngle() const; std::string ToString() const; - Angle& operator=(const Angle&) = default; + constexpr Angle& operator=(const Angle&) = default; - Angle operator+(const Angle& other) const; - Angle operator-(const Angle& other) const; - Angle operator*(T scalar) const; - Angle operator/(T divider) const; + constexpr Angle operator+(const Angle& other) const; + constexpr Angle operator-(const Angle& other) const; + constexpr Angle operator*(T scalar) const; + constexpr Angle operator/(T divider) const; - Angle& operator+=(const Angle& other); - Angle& operator-=(const Angle& other); - Angle& operator*=(T scalar); - Angle& operator/=(T divider); + constexpr Angle& operator+=(const Angle& other); + constexpr Angle& operator-=(const Angle& other); + constexpr Angle& operator*=(T scalar); + constexpr Angle& operator/=(T divider); - bool operator==(const Angle& other) const; - bool operator!=(const Angle& other) const; + constexpr bool operator==(const Angle& other) const; + constexpr bool operator!=(const Angle& other) const; - static Angle FromDegrees(T ang); - static Angle FromRadians(T ang); - static Angle Zero(); + static constexpr Angle FromDegrees(T ang); + static constexpr Angle FromRadians(T ang); + static constexpr Angle Zero(); T value; }; diff --git a/include/Nazara/Math/Angle.inl b/include/Nazara/Math/Angle.inl index 55ac418d9..eee5d084d 100644 --- a/include/Nazara/Math/Angle.inl +++ b/include/Nazara/Math/Angle.inl @@ -32,22 +32,22 @@ namespace Nz return 180; } - template static T FromDegrees(T degrees) + template static constexpr T FromDegrees(T degrees) { return degrees; } - template static T FromRadians(T radians) + template static constexpr T FromRadians(T radians) { return RadianToDegree(radians); } - template static T ToDegrees(T degrees) + template static constexpr T ToDegrees(T degrees) { return degrees; } - template static T ToRadians(T degrees) + template static constexpr T ToRadians(T degrees) { return DegreeToRadian(degrees); } @@ -71,22 +71,22 @@ namespace Nz return T(M_PI); } - template static T FromDegrees(T degrees) + template static constexpr T FromDegrees(T degrees) { return DegreeToRadian(degrees); } - template static T FromRadians(T radians) + template static constexpr T FromRadians(T radians) { return radians; } - template static T ToDegrees(T radians) + template static constexpr T ToDegrees(T radians) { return RadianToDegree(radians); } - template static T ToRadians(T radians) + template static constexpr T ToRadians(T radians) { return radians; } @@ -141,7 +141,7 @@ namespace Nz * \param value value of the angle */ template - Angle::Angle(T angle) : + constexpr Angle::Angle(T angle) : value(angle) { } @@ -152,7 +152,7 @@ namespace Nz * \param value Angle object to copy */ template - Angle::Angle(const Angle& angle) : + constexpr Angle::Angle(const Angle& angle) : value(Detail::AngleUtils::FromDegrees(angle.value)) { } @@ -163,7 +163,7 @@ namespace Nz * \param value Angle object to copy */ template - Angle::Angle(const Angle& angle) : + constexpr Angle::Angle(const Angle& angle) : value(Detail::AngleUtils::FromRadians(angle.value)) { } @@ -225,7 +225,7 @@ namespace Nz * \brief Changes the angle value to zero */ template - Angle& Angle::MakeZero() + constexpr Angle& Angle::MakeZero() { value = T(0); return *this; @@ -239,7 +239,7 @@ namespace Nz * For radian angles, local limits are [-M_PI, M_PI] */ template - void Angle::Normalize() + constexpr Angle& Angle::Normalize() { constexpr T limit = Detail::AngleUtils::template GetLimit(); constexpr T twoLimit = limit * T(2); @@ -247,6 +247,8 @@ namespace Nz value = std::fmod(value, twoLimit); if (value < T(0)) value += twoLimit; + + return *this; } /*! @@ -255,7 +257,7 @@ namespace Nz * \param Angle Angle which will be copied */ template - Angle& Angle::Set(const Angle& ang) + constexpr Angle& Angle::Set(const Angle& ang) { value = ang.value; return *this; @@ -270,7 +272,7 @@ namespace Nz */ template template - Angle& Angle::Set(const Angle& ang) + constexpr Angle& Angle::Set(const Angle& ang) { value = static_cast(ang.value); return *this; @@ -281,7 +283,7 @@ namespace Nz * \return Equivalent degree angle value */ template - T Angle::ToDegrees() const + constexpr T Angle::ToDegrees() const { return Detail::AngleUtils::ToDegrees(value); } @@ -291,7 +293,7 @@ namespace Nz * \return Equivalent degree angle */ template - Angle Angle::ToDegreeAngle() const + constexpr Angle Angle::ToDegreeAngle() const { return DegreeAngle(ToDegrees()); } @@ -329,7 +331,7 @@ namespace Nz * \return Equivalent radian angle value */ template - T Angle::ToRadians() const + constexpr T Angle::ToRadians() const { return Detail::AngleUtils::ToRadians(value); } @@ -339,7 +341,7 @@ namespace Nz * \return Equivalent radian angle */ template - Angle Angle::ToRadianAngle() const + constexpr Angle Angle::ToRadianAngle() const { return RadianAngle(ToRadians()); } @@ -386,7 +388,7 @@ namespace Nz * \param other Angle to add */ template - Angle Angle::operator+(const Angle& other) const + constexpr Angle Angle::operator+(const Angle& other) const { return Angle(value + other.value); } @@ -398,7 +400,7 @@ namespace Nz * \param other Angle to subtract */ template - Angle Angle::operator-(const Angle& other) const + constexpr Angle Angle::operator-(const Angle& other) const { return Angle(value - other.value); } @@ -410,7 +412,7 @@ namespace Nz * \param scalar Multiplier */ template - Angle Angle::operator*(T scalar) const + constexpr Angle Angle::operator*(T scalar) const { return Angle(value * scalar); } @@ -422,7 +424,7 @@ namespace Nz * \param divider Divider */ template - Angle Angle::operator/(T divider) const + constexpr Angle Angle::operator/(T divider) const { return Angle(value / divider); } @@ -434,7 +436,7 @@ namespace Nz * \param other Angle to add */ template - Angle& Angle::operator+=(const Angle& other) + constexpr Angle& Angle::operator+=(const Angle& other) { value += other.value; return *this; @@ -447,7 +449,7 @@ namespace Nz * \param other Angle to subtract */ template - Angle& Angle::operator-=(const Angle& other) + constexpr Angle& Angle::operator-=(const Angle& other) { value -= other.value; return *this; @@ -460,7 +462,7 @@ namespace Nz * \param scalar Multiplier */ template - Angle& Angle::operator*=(T scalar) + constexpr Angle& Angle::operator*=(T scalar) { value *= scalar; return *this; @@ -473,7 +475,7 @@ namespace Nz * \param divider Divider */ template - Angle& Angle::operator/=(T divider) + constexpr Angle& Angle::operator/=(T divider) { value /= divider; return *this; @@ -486,7 +488,7 @@ namespace Nz * \param other The other angle to compare to */ template - bool Angle::operator==(const Angle& other) const + constexpr bool Angle::operator==(const Angle& other) const { return NumberEquals(value, other.value, Detail::AngleUtils::template GetEpsilon()); } @@ -498,7 +500,7 @@ namespace Nz * \param other The other angle to compare to */ template - bool Angle::operator!=(const Angle& other) const + constexpr bool Angle::operator!=(const Angle& other) const { return !NumberEquals(value, other.value, Detail::AngleUtils::template GetEpsilon()); } @@ -510,7 +512,7 @@ namespace Nz * \param ang Degree angle */ template - Angle Angle::FromDegrees(T ang) + constexpr Angle Angle::FromDegrees(T ang) { return Angle(Detail::AngleUtils::FromDegrees(ang)); } @@ -522,7 +524,7 @@ namespace Nz * \param ang Radian angle */ template - Angle Angle::FromRadians(T ang) + constexpr Angle Angle::FromRadians(T ang) { return Angle(Detail::AngleUtils::FromRadians(ang)); } @@ -532,7 +534,7 @@ namespace Nz * \return Zero angle */ template - Angle Angle::Zero() + constexpr Angle Angle::Zero() { Angle angle; angle.MakeZero(); diff --git a/include/Nazara/Math/Config.hpp b/include/Nazara/Math/Config.hpp index a4891a18a..37f9c0de8 100644 --- a/include/Nazara/Math/Config.hpp +++ b/include/Nazara/Math/Config.hpp @@ -35,9 +35,6 @@ /// Each modification of a paramater of the module needs a recompilation of the unit -// Define the radian as unit for angles -#define NAZARA_MATH_ANGLE_RADIAN 0 - // Optimize automatically the operation on affine matrices (Ask several comparisons to determine if the matrix is affine) #define NAZARA_MATH_MATRIX4_CHECK_AFFINE 0 diff --git a/include/Nazara/Math/EulerAngles.hpp b/include/Nazara/Math/EulerAngles.hpp index 4e13e0b8c..07101db0a 100644 --- a/include/Nazara/Math/EulerAngles.hpp +++ b/include/Nazara/Math/EulerAngles.hpp @@ -21,8 +21,8 @@ namespace Nz { public: EulerAngles() = default; - EulerAngles(T P, T Y, T R); - EulerAngles(const T angles[3]); + EulerAngles(DegreeAngle P, DegreeAngle Y, DegreeAngle R); + EulerAngles(const DegreeAngle angles[3]); template EulerAngles(const Angle& angle); //EulerAngles(const Matrix3& mat); EulerAngles(const Quaternion& quat); @@ -34,8 +34,8 @@ namespace Nz EulerAngles& Normalize(); - EulerAngles& Set(T P, T Y, T R); - EulerAngles& Set(const T angles[3]); + EulerAngles& Set(DegreeAngle P, DegreeAngle Y, DegreeAngle R); + EulerAngles& Set(const DegreeAngle angles[3]); template EulerAngles& Set(const Angle& angles); //EulerAngles& Set(const Matrix3& mat); EulerAngles& Set(const Quaternion& quat); @@ -61,7 +61,7 @@ namespace Nz static EulerAngles Zero(); - T pitch, yaw, roll; + DegreeAngle pitch, yaw, roll; }; using EulerAnglesd = EulerAngles; diff --git a/include/Nazara/Math/EulerAngles.inl b/include/Nazara/Math/EulerAngles.inl index 67aa909d5..fccda5f72 100644 --- a/include/Nazara/Math/EulerAngles.inl +++ b/include/Nazara/Math/EulerAngles.inl @@ -32,7 +32,7 @@ namespace Nz */ template - EulerAngles::EulerAngles(T P, T Y, T R) + EulerAngles::EulerAngles(DegreeAngle P, DegreeAngle Y, DegreeAngle R) { Set(P, Y, R); } @@ -44,7 +44,7 @@ namespace Nz */ template - EulerAngles::EulerAngles(const T angles[3]) + EulerAngles::EulerAngles(const DegreeAngle angles[3]) { Set(angles); } @@ -101,17 +101,15 @@ namespace Nz * \brief Normalizes the euler angle * \return A reference to this euler angle with has been normalized * - * \remark Normalization depends on NAZARA_MATH_ANGLE_RADIAN, between 0..2*pi - * * \see NormalizeAngle */ template EulerAngles& EulerAngles::Normalize() { - pitch = NormalizeAngle(pitch); - yaw = NormalizeAngle(yaw); - roll = NormalizeAngle(roll); + pitch.Normalize(); + yaw.Normalize(); + roll.Normalize(); return *this; } @@ -126,7 +124,7 @@ namespace Nz */ template - EulerAngles& EulerAngles::Set(T P, T Y, T R) + EulerAngles& EulerAngles::Set(DegreeAngle P, DegreeAngle Y, DegreeAngle R) { pitch = P; yaw = Y; @@ -143,7 +141,7 @@ namespace Nz */ template - EulerAngles& EulerAngles::Set(const T angles[3]) + EulerAngles& EulerAngles::Set(const DegreeAngle angles[3]) { pitch = angles[0]; yaw = angles[1]; @@ -192,9 +190,9 @@ namespace Nz template EulerAngles& EulerAngles::Set(const EulerAngles& angles) { - pitch = T(angles.pitch); - yaw = T(angles.yaw); - roll = T(angles.roll); + pitch.Set(angles.pitch); + yaw.Set(angles.yaw); + roll.Set(angles.roll); return *this; } @@ -208,13 +206,13 @@ namespace Nz Quaternion EulerAngles::ToQuaternion() const { // XYZ - T c1 = std::cos(ToRadians(yaw) / T(2.0)); - T c2 = std::cos(ToRadians(roll) / T(2.0)); - T c3 = std::cos(ToRadians(pitch) / T(2.0)); + T c1 = (yaw / T(2.0)).GetCos(); + T c2 = (roll / T(2.0)).GetCos(); + T c3 = (pitch / T(2.0)).GetCos(); - T s1 = std::sin(ToRadians(yaw) / T(2.0)); - T s2 = std::sin(ToRadians(roll) / T(2.0)); - T s3 = std::sin(ToRadians(pitch) / T(2.0)); + T s1 = (yaw / T(2.0)).GetSin(); + T s2 = (roll / T(2.0)).GetSin(); + T s3 = (pitch / T(2.0)).GetSin(); return Quaternion(c1 * c2 * c3 - s1 * s2 * s3, s1 * s2 * c3 + c1 * c2 * s3, @@ -310,9 +308,7 @@ namespace Nz template bool EulerAngles::operator==(const EulerAngles& angles) const { - return NumberEquals(pitch, angles.pitch) && - NumberEquals(yaw, angles.yaw) && - NumberEquals(roll, angles.roll); + return pitch == angles.pitch && yaw == angles.yaw && roll == angles.roll; } /*! diff --git a/include/Nazara/Math/Frustum.hpp b/include/Nazara/Math/Frustum.hpp index dce528dc1..f676603c7 100644 --- a/include/Nazara/Math/Frustum.hpp +++ b/include/Nazara/Math/Frustum.hpp @@ -7,6 +7,7 @@ #ifndef NAZARA_FRUSTUM_HPP #define NAZARA_FRUSTUM_HPP +#include #include #include #include @@ -29,7 +30,7 @@ namespace Nz Frustum(const Frustum& frustum) = default; ~Frustum() = default; - Frustum& Build(T angle, T ratio, T zNear, T zFar, const Vector3& eye, const Vector3& target, const Vector3& up = Vector3::Up()); + Frustum& Build(RadianAngle angle, T ratio, T zNear, T zFar, const Vector3& eye, const Vector3& target, const Vector3& up = Vector3::Up()); bool Contains(const BoundingVolume& volume) const; bool Contains(const Box& box) const; diff --git a/include/Nazara/Math/Frustum.inl b/include/Nazara/Math/Frustum.inl index 3dfab07a1..80472e3db 100644 --- a/include/Nazara/Math/Frustum.inl +++ b/include/Nazara/Math/Frustum.inl @@ -40,7 +40,7 @@ namespace Nz * \brief Builds the frustum object * \return A reference to this frustum which is the build up camera's field of view * - * \param angle Unit depends on NAZARA_MATH_ANGLE_RADIAN + * \param angle FOV angle * \param ratio Rendering ratio (typically 16/9 or 4/3) * \param zNear Distance where 'vision' begins * \param zFar Distance where 'vision' ends @@ -50,15 +50,11 @@ namespace Nz */ template - Frustum& Frustum::Build(T angle, T ratio, T zNear, T zFar, const Vector3& eye, const Vector3& target, const Vector3& up) + Frustum& Frustum::Build(RadianAngle angle, T ratio, T zNear, T zFar, const Vector3& eye, const Vector3& target, const Vector3& up) { - #if NAZARA_MATH_ANGLE_RADIAN angle /= T(2.0); - #else - angle = DegreeToRadian(angle / T(2.0)); - #endif - T tangent = std::tan(angle); + T tangent = angle.GetTan(); T nearH = zNear * tangent; T nearW = nearH * ratio; T farH = zFar * tangent; diff --git a/include/Nazara/Math/Matrix4.hpp b/include/Nazara/Math/Matrix4.hpp index f2c0be4ca..ac0253acb 100644 --- a/include/Nazara/Math/Matrix4.hpp +++ b/include/Nazara/Math/Matrix4.hpp @@ -10,6 +10,7 @@ ///FIXME: Matrices column-major, difficile de bosser avec (Tout passer en row-major et transposer dans les shaders ?) #include +#include #include #include @@ -72,7 +73,7 @@ namespace Nz Matrix4& MakeIdentity(); Matrix4& MakeLookAt(const Vector3& eye, const Vector3& target, const Vector3& up = Vector3::Up()); Matrix4& MakeOrtho(T left, T right, T top, T bottom, T zNear = -1.0, T zFar = 1.0); - Matrix4& MakePerspective(T angle, T ratio, T zNear, T zFar); + Matrix4& MakePerspective(RadianAngle angle, T ratio, T zNear, T zFar); Matrix4& MakeRotation(const Quaternion& rotation); Matrix4& MakeScale(const Vector3& scale); Matrix4& MakeTranslation(const Vector3& translation); @@ -124,7 +125,7 @@ namespace Nz static Matrix4 Identity(); static Matrix4 LookAt(const Vector3& eye, const Vector3& target, const Vector3& up = Vector3::Up()); static Matrix4 Ortho(T left, T right, T top, T bottom, T zNear = -1.0, T zFar = 1.0); - static Matrix4 Perspective(T angle, T ratio, T zNear, T zFar); + static Matrix4 Perspective(RadianAngle angle, T ratio, T zNear, T zFar); static Matrix4 Rotate(const Quaternion& rotation); static Matrix4 Scale(const Vector3& scale); static Matrix4 Translate(const Vector3& translation); diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index e1482511c..450ef8d6a 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -903,7 +903,7 @@ namespace Nz * \brief Makes the matrix a 'perspective matrix' * \return A reference to this matrix transformed in 'perspective matrix' * - * \param angle Unit depends on NAZARA_MATH_ANGLE_RADIAN + * \param angle FOV angle * \param ratio Rendering ratio (typically 16/9 or 4/3) * \param zNear Distance where 'vision' begins * \param zFar Distance where 'vision' ends @@ -912,16 +912,12 @@ namespace Nz */ template - Matrix4& Matrix4::MakePerspective(T angle, T ratio, T zNear, T zFar) + Matrix4& Matrix4::MakePerspective(RadianAngle angle, T ratio, T zNear, T zFar) { - // http://msdn.microsoft.com/en-us/library/windows/desktop/bb204945(v=vs.85).aspx - #if NAZARA_MATH_ANGLE_RADIAN - angle /= T(2.0); - #else - angle = DegreeToRadian(angle / T(2.0)); - #endif + // https://docs.microsoft.com/fr-fr/windows/win32/direct3d10/d3d10-d3dxmatrixperspectivefovrh + angle = RadianAngle(M_PI_2) - angle / T(2.0); - T yScale = std::tan(static_cast(M_PI_2) - angle); + T yScale = angle.GetTan(); Set(yScale / ratio, T(0.0), T(0.0), T(0.0), T(0.0), yScale, T(0.0), T(0.0), @@ -1598,7 +1594,7 @@ namespace Nz * \brief Shorthand for the 'perspective' matrix * \return A Matrix4 which is the 'perspective' matrix * - * \param angle Unit depends on NAZARA_MATH_ANGLE_RADIAN + * \param angle FOV angle * \param ratio Rendering ratio (typically 16/9 or 4/3) * \param zNear Distance where 'vision' begins * \param zFar Distance where 'vision' ends @@ -1607,7 +1603,7 @@ namespace Nz */ template - Matrix4 Matrix4::Perspective(T angle, T ratio, T zNear, T zFar) + Matrix4 Matrix4::Perspective(RadianAngle angle, T ratio, T zNear, T zFar) { Matrix4 matrix; matrix.MakePerspective(angle, ratio, zNear, zFar); diff --git a/include/Nazara/Math/Quaternion.hpp b/include/Nazara/Math/Quaternion.hpp index 96af1dbfd..c8f112d4f 100644 --- a/include/Nazara/Math/Quaternion.hpp +++ b/include/Nazara/Math/Quaternion.hpp @@ -24,7 +24,7 @@ namespace Nz 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(RadianAngle angle, const Vector3& axis); Quaternion(const T quat[4]); //Quaternion(const Matrix3& mat); template explicit Quaternion(const Quaternion& quat); @@ -53,7 +53,7 @@ namespace Nz 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(RadianAngle angle, const Vector3& normalizedAxis); Quaternion& Set(const T quat[4]); //Quaternion& Set(const Matrix3& mat); template Quaternion& Set(const Quaternion& quat); diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index abba22e7c..aa46bbd7c 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -66,12 +66,12 @@ namespace Nz /*! * \brief Constructs a Quaternion object from an angle and a direction * - * \param angle Unit depends of NAZARA_MATH_ANGLE_RADIAN + * \param angle Angle to rotate along the axis * \param axis Vector3 which represents a direction, no need to be normalized */ template - Quaternion::Quaternion(T angle, const Vector3& axis) + Quaternion::Quaternion(RadianAngle angle, const Vector3& axis) { Set(angle, axis); } @@ -386,27 +386,23 @@ namespace Nz * \brief Sets this quaternion from rotation specified by axis and angle * \return A reference to this quaternion * - * \param angle Unit depends of NAZARA_MATH_ANGLE_RADIAN + * \param angle Angle to rotate along the axis * \param axis Vector3 which represents a direction, no need to be normalized */ template - Quaternion& Quaternion::Set(T angle, const Vector3& axis) + Quaternion& Quaternion::Set(RadianAngle angle, const Vector3& axis) { - #if !NAZARA_MATH_ANGLE_RADIAN - angle = DegreeToRadian(angle); - #endif - angle /= T(2.0); Vector3 normalizedAxis = axis.GetNormal(); - T sinAngle = std::sin(angle); + auto sincos = angle.GetSinCos(); - w = std::cos(angle); - x = normalizedAxis.x * sinAngle; - y = normalizedAxis.y * sinAngle; - z = normalizedAxis.z * sinAngle; + w = sincos.second; + x = normalizedAxis.x * sincos.first; + y = normalizedAxis.y * sincos.first; + z = normalizedAxis.z * sincos.first; return Normalize(); } @@ -488,15 +484,15 @@ namespace Nz T test = x * y + z * w; if (test > T(0.499)) // singularity at north pole - return EulerAngles(T(0.0), FromRadians(T(2.0) * std::atan2(x, w)), FromDegrees(T(90.0))); + return EulerAngles(DegreeAngle(T(0.0)), RadianAngle(T(2.0) * std::atan2(x, w)), DegreeAngle(T(90.0))); if (test < T(-0.499)) // singularity at south pole - return EulerAngles(T(0.0), FromRadians(T(-2.0) * std::atan2(x, w)), FromDegrees(T(-90.0))); + return EulerAngles(DegreeAngle(T(0.0)), RadianAngle(T(-2.0) * std::atan2(x, w)), DegreeAngle(T(-90.0))); - return EulerAngles(FromRadians(std::atan2(T(2.0) * x * w - T(2.0) * y * z, T(1.0) - T(2.0) * x * x - T(2.0) * z * z)), - FromRadians(std::atan2(T(2.0) * y * w - T(2.0) * x * z, T(1.0) - T(2.0) * y * y - T(2.0) * z * z)), - FromRadians(std::asin(T(2.0) * test))); + return EulerAngles(RadianAngle(std::atan2(T(2.0) * x * w - T(2.0) * y * z, T(1.0) - T(2.0) * x * x - T(2.0) * z * z)), + RadianAngle(std::atan2(T(2.0) * y * w - T(2.0) * x * z, T(1.0) - T(2.0) * y * y - T(2.0) * z * z)), + RadianAngle(std::asin(T(2.0) * test))); } /*! diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index bc0d6c9fb..35136fc31 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -33,7 +34,7 @@ namespace Nz ~Vector2() = default; T AbsDotProduct(const Vector2& vec) const; - T AngleBetween(const Vector2& vec) const; + RadianAngle AngleBetween(const Vector2& vec) const; template U Distance(const Vector2& vec) const; diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index 1ecb7cebf..d9dfe492a 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -97,7 +97,7 @@ namespace Nz /*! * \brief Calculates the angle between two vectors in orthonormal basis - * \return The angle unit depends of NAZARA_MATH_ANGLE_RADIAN, you may want to normalize it to the range 0..2*pi with NormalizeAngle + * \return The angle * * \param vec The other vector to measure the angle with * @@ -107,9 +107,9 @@ namespace Nz */ template - T Vector2::AngleBetween(const Vector2& vec) const + RadianAngle Vector2::AngleBetween(const Vector2& vec) const { - return FromRadians(std::atan2(vec.y, vec.x) - std::atan2(y, x)); + return std::atan2(vec.y, vec.x) - std::atan2(y, x); } /*! diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 9f02cffd7..19777949e 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -34,7 +35,7 @@ namespace Nz ~Vector3() = default; T AbsDotProduct(const Vector3& vec) const; - T AngleBetween(const Vector3& vec) const; + RadianAngle AngleBetween(const Vector3& vec) const; Vector3 CrossProduct(const Vector3& vec) const; diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index 5c73a33d0..245d0dd48 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -107,7 +107,7 @@ namespace Nz /*! * \brief Calculates the angle between two vectors in orthonormal basis - * \return The angle unit depends of NAZARA_MATH_ANGLE_RADIAN in the range 0..pi + * \return The angle * * \param vec The other vector to measure the angle with * @@ -118,7 +118,7 @@ namespace Nz * \see NormalizeAngle */ template - T Vector3::AngleBetween(const Vector3& vec) const + RadianAngle Vector3::AngleBetween(const Vector3& vec) const { // sqrt(a) * sqrt(b) = sqrt(a*b) T divisor = std::sqrt(GetSquaredLength() * vec.GetSquaredLength()); @@ -134,7 +134,7 @@ namespace Nz #endif T alpha = DotProduct(vec) / divisor; - return FromRadians(std::acos(Clamp(alpha, T(-1.0), T(1.0)))); + return std::acos(Clamp(alpha, T(-1.0), T(1.0))); } /*! diff --git a/src/NazaraSDK/Systems/PhysicsSystem3D.cpp b/src/NazaraSDK/Systems/PhysicsSystem3D.cpp index 66d94636b..ccc45b7a8 100644 --- a/src/NazaraSDK/Systems/PhysicsSystem3D.cpp +++ b/src/NazaraSDK/Systems/PhysicsSystem3D.cpp @@ -128,9 +128,7 @@ namespace Ndk { Nz::Quaternionf transition = newRotation * oldRotation.GetConjugate(); Nz::EulerAnglesf angles = transition.ToEulerAngles(); - Nz::Vector3f angularVelocity(Nz::ToRadians(angles.pitch * invElapsedTime), - Nz::ToRadians(angles.yaw * invElapsedTime), - Nz::ToRadians(angles.roll * invElapsedTime)); + Nz::Vector3f angularVelocity((angles.pitch * invElapsedTime).ToRadians(), (angles.yaw * invElapsedTime).ToRadians(), (angles.roll * invElapsedTime).ToRadians()); physObj->SetRotation(oldRotation); physObj->SetAngularVelocity(angularVelocity); diff --git a/tests/Engine/Math/AlgorithmMath.cpp b/tests/Engine/Math/AlgorithmMath.cpp index de21817f4..e93734605 100644 --- a/tests/Engine/Math/AlgorithmMath.cpp +++ b/tests/Engine/Math/AlgorithmMath.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -208,62 +209,62 @@ TEST_CASE("NormalizeAngle", "[MATH][ALGORITHM]") { SECTION("-90 should be normalized to +270") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(-90.f)) == Nz::FromDegrees(270.f)); + REQUIRE(Nz::DegreeAnglef(-90.f).Normalize() == Nz::DegreeAnglef(270.f)); } SECTION("-540 should be normalized to +180") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(-540.f)) == Nz::FromDegrees(180.f)); + REQUIRE(Nz::DegreeAnglef(-540.f).Normalize() == Nz::DegreeAnglef(180.f)); } SECTION("0 should remain 0") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(0.f)) == Nz::FromDegrees(0.f)); + REQUIRE(Nz::DegreeAnglef(0.f).Normalize() == Nz::DegreeAnglef(0.f)); } SECTION("90 should remain 90") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(90.f)) == Nz::FromDegrees(90.f)); + REQUIRE(Nz::DegreeAnglef(90.f).Normalize() == Nz::DegreeAnglef(90.f)); } SECTION("360 should be normalized to 0") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(360.f)) == Nz::FromDegrees(0.f)); + REQUIRE(Nz::DegreeAnglef(360.f).Normalize() == Nz::DegreeAnglef(0.f)); } SECTION("450 should be normalized to 90") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(450.f)) == Nz::FromDegrees(90.f)); + REQUIRE(Nz::DegreeAnglef(450.f).Normalize() == Nz::DegreeAnglef(90.f)); } SECTION("-90 should be normalized to +270") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(-90)) == Nz::FromDegrees(270)); + REQUIRE(Nz::DegreeAnglef(-90).Normalize() == Nz::DegreeAnglef(270)); } SECTION("-540 should be normalized to +180") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(-540)) == Nz::FromDegrees(180)); + REQUIRE(Nz::DegreeAnglef(-540).Normalize() == Nz::DegreeAnglef(180)); } SECTION("0 should remain 0") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(0)) == Nz::FromDegrees(0)); + REQUIRE(Nz::DegreeAnglef(0).Normalize() == Nz::DegreeAnglef(0)); } SECTION("90 should remain 90") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(90)) == Nz::FromDegrees(90)); + REQUIRE(Nz::DegreeAnglef(90).Normalize() == Nz::DegreeAnglef(90)); } SECTION("360 should be normalized to 0") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(360)) == Nz::FromDegrees(0)); + REQUIRE(Nz::DegreeAnglef(360).Normalize() == Nz::DegreeAnglef(0)); } SECTION("450 should be normalized to 90") { - REQUIRE(Nz::NormalizeAngle(Nz::FromDegrees(450)) == Nz::FromDegrees(90)); + REQUIRE(Nz::DegreeAnglef(450).Normalize() == Nz::DegreeAnglef(90)); } } diff --git a/tests/Engine/Math/EulerAngles.cpp b/tests/Engine/Math/EulerAngles.cpp index 01bfaecff..a8a6bf35f 100644 --- a/tests/Engine/Math/EulerAngles.cpp +++ b/tests/Engine/Math/EulerAngles.cpp @@ -16,8 +16,8 @@ SCENARIO("EulerAngles", "[MATH][EULERANGLES]") WHEN("We do some operations") { - Nz::EulerAnglesf euler90(Nz::FromDegrees(90.f), Nz::FromDegrees(90.f), Nz::FromDegrees(90.f)); - Nz::EulerAnglesf euler270(Nz::FromDegrees(270.f), Nz::FromDegrees(270.f), Nz::FromDegrees(270.f)); + Nz::EulerAnglesf euler90(Nz::DegreeAnglef(90.f), Nz::DegreeAnglef(90.f), Nz::DegreeAnglef(90.f)); + Nz::EulerAnglesf euler270(Nz::DegreeAnglef(270.f), Nz::DegreeAnglef(270.f), Nz::DegreeAnglef(270.f)); Nz::EulerAnglesf euler360 = euler90 + euler270; euler360.Normalize(); @@ -45,9 +45,9 @@ SCENARIO("EulerAngles", "[MATH][EULERANGLES]") GIVEN("Three rotation of 90 on each axis") { - Nz::EulerAnglesf euler90P(Nz::FromDegrees(90.f), 0.f, 0.f); - Nz::EulerAnglesf euler90Y(0.f, Nz::FromDegrees(90.f), 0.f); - Nz::EulerAnglesf euler90R(0.f, 0.f, Nz::FromDegrees(90.f)); + Nz::EulerAnglesf euler90P(Nz::DegreeAnglef(90.f), 0.f, 0.f); + Nz::EulerAnglesf euler90Y(0.f, Nz::DegreeAnglef(90.f), 0.f); + Nz::EulerAnglesf euler90R(0.f, 0.f, Nz::DegreeAnglef(90.f)); WHEN("We transform the axis") { @@ -70,37 +70,37 @@ SCENARIO("EulerAngles", "[MATH][EULERANGLES]") { THEN("These results are expected") { - CHECK(Nz::EulerAngles(Nz::FromDegrees(45.f), 0.f, 0.f) == Nz::EulerAngles(Nz::Quaternionf(0.923879504204f, 0.382683455944f, 0.f, 0.f).ToEulerAngles())); - CHECK(Nz::EulerAngles(0.f, Nz::FromDegrees(45.f), 0.f) == Nz::EulerAngles(Nz::Quaternionf(0.923879504204f, 0.f, 0.382683455944f, 0.f).ToEulerAngles())); - CHECK(Nz::EulerAngles(0.f, 0.f, Nz::FromDegrees(45.f)) == Nz::EulerAngles(Nz::Quaternionf(0.923879504204f, 0.f, 0.f, 0.382683455944f).ToEulerAngles())); + CHECK(Nz::EulerAnglesf(Nz::DegreeAnglef(45.f), 0.f, 0.f) == Nz::EulerAnglesf(Nz::Quaternionf(0.923879504204f, 0.382683455944f, 0.f, 0.f).ToEulerAngles())); + CHECK(Nz::EulerAnglesf(0.f, Nz::DegreeAnglef(45.f), 0.f) == Nz::EulerAnglesf(Nz::Quaternionf(0.923879504204f, 0.f, 0.382683455944f, 0.f).ToEulerAngles())); + CHECK(Nz::EulerAnglesf(0.f, 0.f, Nz::DegreeAnglef(45.f)) == Nz::EulerAnglesf(Nz::Quaternionf(0.923879504204f, 0.f, 0.f, 0.382683455944f).ToEulerAngles())); } } } GIVEN("Three euler angles: (0, 22.5, 22.5), (90, 90, 0) and (30, 0, 30)") { - Nz::EulerAnglesf euler45(Nz::FromDegrees(0.f), Nz::FromDegrees(22.5f), Nz::FromDegrees(22.5f)); - Nz::EulerAnglesf euler90(Nz::FromDegrees(90.f), Nz::FromDegrees(90.f), Nz::FromDegrees(0.f)); - Nz::EulerAnglesf euler30(Nz::FromDegrees(30.f), Nz::FromDegrees(0.f), Nz::FromDegrees(30.f)); + Nz::EulerAnglesf euler45(Nz::DegreeAnglef(0.f), Nz::DegreeAnglef(22.5f), Nz::DegreeAnglef(22.5f)); + Nz::EulerAnglesf euler90(Nz::DegreeAnglef(90.f), Nz::DegreeAnglef(90.f), Nz::DegreeAnglef(0.f)); + Nz::EulerAnglesf euler30(Nz::DegreeAnglef(30.f), Nz::DegreeAnglef(0.f), Nz::DegreeAnglef(30.f)); WHEN("We convert them to quaternion") { THEN("And then convert to euler angles, we have identity") { Nz::EulerAnglesf tmp = Nz::Quaternionf(euler45.ToQuaternion()).ToEulerAngles(); - CHECK(tmp.pitch == Approx(0.f)); - CHECK(tmp.yaw == Approx(22.5f)); - CHECK(tmp.roll == Approx(22.5f)); + CHECK(tmp.pitch.ToDegrees() == Approx(0.f)); + CHECK(tmp.yaw.ToDegrees() == Approx(22.5f)); + CHECK(tmp.roll.ToDegrees() == Approx(22.5f)); tmp = Nz::Quaternionf(euler90.ToQuaternion()).ToEulerAngles(); - CHECK(tmp.pitch == Approx(90.f)); - CHECK(tmp.yaw == Approx(90.f)); - CHECK(tmp.roll == Approx(0.f)); + CHECK(tmp.pitch.ToDegrees() == Approx(90.f)); + CHECK(tmp.yaw.ToDegrees() == Approx(90.f)); + CHECK(tmp.roll.ToDegrees() == Approx(0.f)); tmp = Nz::Quaternionf(euler30.ToQuaternion()).ToEulerAngles(); - CHECK(tmp.pitch == Approx(30.f)); - CHECK(tmp.yaw == Approx(0.f).margin(0.0001f)); - CHECK(tmp.roll == Approx(30.f)); + CHECK(tmp.pitch.ToDegrees() == Approx(30.f)); + CHECK(tmp.yaw.ToDegrees() == Approx(0.f).margin(0.0001f)); + CHECK(tmp.roll.ToDegrees() == Approx(30.f)); } } } diff --git a/tests/Engine/Math/Frustum.cpp b/tests/Engine/Math/Frustum.cpp index d9fedebdd..3abd36723 100644 --- a/tests/Engine/Math/Frustum.cpp +++ b/tests/Engine/Math/Frustum.cpp @@ -6,7 +6,7 @@ SCENARIO("Frustum", "[MATH][FRUSTUM]") GIVEN("One frustum (90, 1, 1, 1000, (0, 0, 0), (1, 0, 0))") { Nz::Frustumf frustum; - frustum.Build(Nz::FromDegrees(90.f), 1.f, 1.f, 1000.f, Nz::Vector3f::Zero(), Nz::Vector3f::UnitX()); + frustum.Build(Nz::DegreeAnglef(90.f), 1.f, 1.f, 1000.f, Nz::Vector3f::Zero(), Nz::Vector3f::UnitX()); WHEN("We ask for intersection with objects outside the frustum") { diff --git a/tests/Engine/Math/Matrix4.cpp b/tests/Engine/Math/Matrix4.cpp index ca4760e7b..7030e68a6 100644 --- a/tests/Engine/Math/Matrix4.cpp +++ b/tests/Engine/Math/Matrix4.cpp @@ -102,42 +102,42 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]") { THEN("Rotation around X") { - transformedMatrix.MakeTransform(Nz::Vector3f::Zero(), Nz::EulerAnglesf(Nz::FromDegrees(45.f), 0.f, 0.f).ToQuaternion()); + transformedMatrix.MakeTransform(Nz::Vector3f::Zero(), Nz::EulerAnglesf(Nz::DegreeAnglef(45.f), 0.f, 0.f).ToQuaternion()); Nz::Matrix4f rotation45X(1.f, 0.f, 0.f, 0.f, 0.f, std::sqrt(2.f) / 2.f, std::sqrt(2.f) / 2.f, 0.f, 0.f, -std::sqrt(2.f) / 2.f, std::sqrt(2.f) / 2.f, 0.f, 0.f, 0.f, 0.f, 1.f); CHECK(transformedMatrix == rotation45X); - transformedMatrix.MakeTransform(Nz::Vector3f::Unit(), Nz::EulerAnglesf(Nz::FromDegrees(45.f), 0.f, 0.f).ToQuaternion()); + transformedMatrix.MakeTransform(Nz::Vector3f::Unit(), Nz::EulerAnglesf(Nz::DegreeAnglef(45.f), 0.f, 0.f).ToQuaternion()); rotation45X.ApplyTranslation(Nz::Vector3f::Unit()); CHECK(transformedMatrix == rotation45X); } THEN("Rotation around Y") { - transformedMatrix.MakeTransform(Nz::Vector3f::Zero(), Nz::EulerAnglesf(0.f, Nz::FromDegrees(45.f), 0.f).ToQuaternion()); + transformedMatrix.MakeTransform(Nz::Vector3f::Zero(), Nz::EulerAnglesf(0.f, Nz::DegreeAnglef(45.f), 0.f).ToQuaternion()); Nz::Matrix4f rotation45Y(std::sqrt(2.f) / 2.f, 0.f, -std::sqrt(2.f) / 2.f, 0.f, 0.f, 1.f, 0.f, 0.f, std::sqrt(2.f) / 2.f, 0.f, std::sqrt(2.f) / 2.f, 0.f, 0.f, 0.f, 0.f, 1.f); CHECK(transformedMatrix == rotation45Y); - transformedMatrix.MakeTransform(Nz::Vector3f::Unit(), Nz::EulerAnglesf(0.f, Nz::FromDegrees(45.f), 0.f).ToQuaternion()); + transformedMatrix.MakeTransform(Nz::Vector3f::Unit(), Nz::EulerAnglesf(0.f, Nz::DegreeAnglef(45.f), 0.f).ToQuaternion()); rotation45Y.ApplyTranslation(Nz::Vector3f::Unit()); CHECK(transformedMatrix == rotation45Y); } THEN("Rotation around Z") { - transformedMatrix.MakeTransform(Nz::Vector3f::Zero(), Nz::EulerAnglesf(0.f, 0.f, Nz::FromDegrees(45.f)).ToQuaternion()); + transformedMatrix.MakeTransform(Nz::Vector3f::Zero(), Nz::EulerAnglesf(0.f, 0.f, Nz::DegreeAnglef(45.f)).ToQuaternion()); Nz::Matrix4f rotation45Z( std::sqrt(2.f) / 2.f, std::sqrt(2.f) / 2.f, 0.f, 0.f, -std::sqrt(2.f) / 2.f, std::sqrt(2.f) / 2.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f); CHECK(transformedMatrix == rotation45Z); - transformedMatrix.MakeTransform(Nz::Vector3f::Unit(), Nz::EulerAnglesf(Nz::EulerAnglesf(0.f, 0.f, Nz::FromDegrees(45.f)).ToQuaternion())); + transformedMatrix.MakeTransform(Nz::Vector3f::Unit(), Nz::EulerAnglesf(Nz::EulerAnglesf(0.f, 0.f, Nz::DegreeAnglef(45.f)).ToQuaternion())); rotation45Z.ApplyTranslation(Nz::Vector3f::Unit()); CHECK(transformedMatrix == rotation45Z); } @@ -157,7 +157,7 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]") WHEN("We rotate it from pitch 30") { - Nz::Quaternionf rotation(Nz::EulerAnglesf(Nz::FromDegrees(30.f), 0.f, 0.f)); + Nz::Quaternionf rotation(Nz::EulerAnglesf(Nz::DegreeAnglef(30.f), 0.f, 0.f)); identity.ApplyRotation(rotation); THEN("We should retrieve it") @@ -168,7 +168,7 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]") WHEN("We rotate it from yaw 30") { - Nz::Quaternionf rotation(Nz::EulerAnglesf(0.f, Nz::FromDegrees(30.f), 0.f)); + Nz::Quaternionf rotation(Nz::EulerAnglesf(0.f, Nz::DegreeAnglef(30.f), 0.f)); identity.ApplyRotation(rotation); THEN("We should retrieve it") @@ -179,7 +179,7 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]") WHEN("We rotate it from roll 30") { - Nz::Quaternionf rotation(Nz::EulerAnglesf(0.f, 0.f, Nz::FromDegrees(30.f))); + Nz::Quaternionf rotation(Nz::EulerAnglesf(0.f, 0.f, Nz::DegreeAnglef(30.f))); identity.ApplyRotation(rotation); THEN("We should retrieve it") @@ -190,7 +190,7 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]") WHEN("We rotate it from a strange rotation") { - Nz::Quaternionf rotation(Nz::EulerAnglesf(Nz::FromDegrees(10.f), Nz::FromDegrees(20.f), Nz::FromDegrees(30.f))); + Nz::Quaternionf rotation(Nz::EulerAnglesf(Nz::DegreeAnglef(10.f), Nz::DegreeAnglef(20.f), Nz::DegreeAnglef(30.f))); identity.ApplyRotation(rotation); THEN("We should retrieve it") @@ -213,7 +213,7 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]") AND_THEN("With a rotation") { - identity.ApplyRotation(Nz::EulerAnglesf(Nz::FromDegrees(10.f), Nz::FromDegrees(20.f), Nz::FromDegrees(30.f))); + identity.ApplyRotation(Nz::EulerAnglesf(Nz::DegreeAnglef(10.f), Nz::DegreeAnglef(20.f), Nz::DegreeAnglef(30.f))); Nz::Vector3f retrievedScale = identity.GetScale(); CHECK(retrievedScale.x == Approx(scale.x)); CHECK(retrievedScale.y == Approx(scale.y)); @@ -248,12 +248,12 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]") Nz::Matrix4f simple = Nz::Matrix4f::Transform(simpleTranslation, simpleRotation, simpleScale); Nz::Vector3f complexTranslation = Nz::Vector3f(-5.f, 7.f, 3.5f); - Nz::Quaternionf complexRotation = Nz::EulerAnglesf(Nz::FromDegrees(-22.5f), Nz::FromDegrees(30.f), Nz::FromDegrees(15.f)); + Nz::Quaternionf complexRotation = Nz::EulerAnglesf(Nz::DegreeAnglef(-22.5f), Nz::DegreeAnglef(30.f), Nz::DegreeAnglef(15.f)); Nz::Vector3f complexScale = Nz::Vector3f(1.f, 2.f, 0.5f); Nz::Matrix4f complex = Nz::Matrix4f::Transform(complexTranslation, complexRotation, complexScale); Nz::Vector3f oppositeTranslation = Nz::Vector3f(-5.f, 7.f, 3.5f); - Nz::Quaternionf oppositeRotation = Nz::EulerAnglesf(Nz::FromDegrees(-90.f), Nz::FromDegrees(0.f), Nz::FromDegrees(0.f)); + Nz::Quaternionf oppositeRotation = Nz::EulerAnglesf(Nz::DegreeAnglef(-90.f), Nz::DegreeAnglef(0.f), Nz::DegreeAnglef(0.f)); Nz::Vector3f oppositeScale = Nz::Vector3f(1.f, 2.f, 0.5f); Nz::Matrix4f opposite = Nz::Matrix4f::Transform(oppositeTranslation, oppositeRotation, oppositeScale); @@ -280,7 +280,7 @@ SCENARIO("Matrix4", "[MATH][MATRIX4]") { Nz::Vector3f translation(-5.f, 3.f, 0.5); Nz::Matrix4f initial = Nz::Matrix4f::Translate(translation); - Nz::Quaternionf rotation = Nz::EulerAnglesf(Nz::FromDegrees(30.f), Nz::FromDegrees(-90.f), 0.f); + Nz::Quaternionf rotation = Nz::EulerAnglesf(Nz::DegreeAnglef(30.f), Nz::DegreeAnglef(-90.f), 0.f); initial.ApplyRotation(rotation); Nz::Matrix4f simple = Nz::Matrix4f::Transform(-translation, rotation.GetInverse(), Nz::Vector3f::Unit()); diff --git a/tests/Engine/Math/Quaternion.cpp b/tests/Engine/Math/Quaternion.cpp index 3cae63386..0bf9d40e6 100644 --- a/tests/Engine/Math/Quaternion.cpp +++ b/tests/Engine/Math/Quaternion.cpp @@ -5,7 +5,7 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]") { GIVEN("Two quaternions (0, 1, 0, 0)") { - Nz::Quaternionf firstQuaternion(Nz::FromDegrees(180.f), Nz::Vector3f::UnitX()); + Nz::Quaternionf firstQuaternion(Nz::DegreeAnglef(180.f), Nz::Vector3f::UnitX()); Nz::Quaternionf secondQuaternion(0.f, 1.f, 0.f, 0.f); WHEN("We compare them") @@ -97,7 +97,7 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]") GIVEN("Two different quaternions (10, (1, 0, 0) and (20, (1, 0, 0))") { - Nz::Quaternionf x10 = Nz::Quaternionf(Nz::FromDegrees(10.f), Nz::Vector3f::UnitX()); + Nz::Quaternionf x10 = Nz::Quaternionf(Nz::DegreeAnglef(10.f), Nz::Vector3f::UnitX()); Nz::Quaternionf x20 = x10 * x10; Nz::Quaternionf x30a = x10 * x20; @@ -107,16 +107,16 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]") { THEN("These results are expected") { - REQUIRE(x20 == Nz::Quaternionf(Nz::FromDegrees(20.f), Nz::Vector3f::UnitX())); + REQUIRE(x20 == Nz::Quaternionf(Nz::DegreeAnglef(20.f), Nz::Vector3f::UnitX())); REQUIRE(x30a == x30b); } } WHEN("Convert euler to quaternion") { - Nz::Quaternionf X45(Nz::EulerAnglesf(Nz::FromDegrees(45.f), 0.f, 0.f)); - Nz::Quaternionf Y45(Nz::EulerAnglesf(0.f, Nz::FromDegrees(45.f), 0.f)); - Nz::Quaternionf Z45(Nz::EulerAnglesf(0.f, 0.f, Nz::FromDegrees(45.f))); + Nz::Quaternionf X45(Nz::EulerAnglesf(Nz::DegreeAnglef(45.f), 0.f, 0.f)); + Nz::Quaternionf Y45(Nz::EulerAnglesf(0.f, Nz::DegreeAnglef(45.f), 0.f)); + Nz::Quaternionf Z45(Nz::EulerAnglesf(0.f, 0.f, Nz::DegreeAnglef(45.f))); THEN("They must be equal") { @@ -159,11 +159,11 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]") AND_THEN("The half of 45 is 22.5") { - Nz::Quaternionf quaterionA(Nz::FromDegrees(0.f), Nz::Vector3f::UnitZ()); - Nz::Quaternionf quaterionB(Nz::FromDegrees(45.f), Nz::Vector3f::UnitZ()); + Nz::Quaternionf quaterionA(Nz::DegreeAnglef(0.f), Nz::Vector3f::UnitZ()); + Nz::Quaternionf quaterionB(Nz::DegreeAnglef(45.f), Nz::Vector3f::UnitZ()); Nz::Quaternionf quaternionC = Nz::Quaternionf::Slerp(quaterionA, quaterionB, 0.5f); - Nz::Quaternionf unitZ225(Nz::FromDegrees(22.5f), Nz::Vector3f::UnitZ()); + Nz::Quaternionf unitZ225(Nz::DegreeAnglef(22.5f), Nz::Vector3f::UnitZ()); REQUIRE(quaternionC.w == Approx(unitZ225.w)); REQUIRE(quaternionC.x == Approx(unitZ225.x)); REQUIRE(quaternionC.y == Approx(unitZ225.y)); @@ -176,21 +176,21 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]") THEN("The rotation in right-handed is 90 degree on z") { Nz::Quaternionf rotationBetweenXY = Nz::Quaternionf::RotationBetween(Nz::Vector3f::UnitX(), Nz::Vector3f::UnitY()); - Nz::Quaternionf rotation90Z(Nz::FromDegrees(90.f), Nz::Vector3f::UnitZ()); + Nz::Quaternionf rotation90Z(Nz::DegreeAnglef(90.f), Nz::Vector3f::UnitZ()); REQUIRE(rotation90Z == rotationBetweenXY); } THEN("The rotation in right-handed is 90 degree on y") { Nz::Quaternionf rotationBetweenXZ = Nz::Quaternionf::RotationBetween(Nz::Vector3f::UnitX(), Nz::Vector3f::UnitZ()); - Nz::Quaternionf rotation90Y(Nz::FromDegrees(-90.f), Nz::Vector3f::UnitY()); + Nz::Quaternionf rotation90Y(Nz::DegreeAnglef(-90.f), Nz::Vector3f::UnitY()); REQUIRE(rotation90Y == rotationBetweenXZ); } THEN("The rotation in right-handed is 90 degree on x") { Nz::Quaternionf rotationBetweenYZ = Nz::Quaternionf::RotationBetween(Nz::Vector3f::UnitY(), Nz::Vector3f::UnitZ()); - Nz::Quaternionf rotation90X(Nz::FromDegrees(90.f), Nz::Vector3f::UnitX()); + Nz::Quaternionf rotation90X(Nz::DegreeAnglef(90.f), Nz::Vector3f::UnitX()); REQUIRE(rotation90X == rotationBetweenYZ); } @@ -224,21 +224,21 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]") { THEN("Those are equal to") { - CHECK(Nz::NumberEquals(rotation90X.ToEulerAngles().pitch, Nz::FromDegrees(90.f), 0.1f)); - CHECK(Nz::NumberEquals(rotation90Y.ToEulerAngles().yaw, Nz::FromDegrees(90.f), 0.1f)); - CHECK(Nz::NumberEquals(rotation90Z.ToEulerAngles().roll, Nz::FromDegrees(90.f), 0.1f)); + CHECK(Nz::NumberEquals(rotation90X.ToEulerAngles().pitch.ToDegrees(), 90.f, 0.1f)); + CHECK(Nz::NumberEquals(rotation90Y.ToEulerAngles().yaw.ToDegrees(), 90.f, 0.1f)); + CHECK(Nz::NumberEquals(rotation90Z.ToEulerAngles().roll.ToDegrees(), 90.f, 0.1f)); CHECK(rotation180X == Nz::EulerAnglesf(180.f, 0.f, 0.f)); CHECK(rotation180Y == Nz::EulerAnglesf(0.f, 180.f, 0.f)); CHECK(rotation180Z == Nz::EulerAnglesf(0.f, 0.f, 180.f)); - CHECK(Nz::NumberEquals(rotation270X.ToEulerAngles().pitch, Nz::FromDegrees(-90.f), 0.1f)); - CHECK(Nz::NumberEquals(rotation270Y.ToEulerAngles().yaw, Nz::FromDegrees(-90.f), 0.1f)); - CHECK(Nz::NumberEquals(rotation270Z.ToEulerAngles().roll, Nz::FromDegrees(-90.f), 0.1f)); + CHECK(Nz::NumberEquals(rotation270X.ToEulerAngles().pitch.ToDegrees(), -90.f, 0.1f)); + CHECK(Nz::NumberEquals(rotation270Y.ToEulerAngles().yaw.ToDegrees(), -90.f, 0.1f)); + CHECK(Nz::NumberEquals(rotation270Z.ToEulerAngles().roll.ToDegrees(), -90.f, 0.1f)); - CHECK(Nz::NumberEquals(special.ToEulerAngles().pitch, Nz::FromDegrees(0.f), 0.1f)); - CHECK(Nz::NumberEquals(special.ToEulerAngles().yaw, Nz::FromDegrees(1.f), 0.1f)); - CHECK(Nz::NumberEquals(special.ToEulerAngles().roll, Nz::FromDegrees(90.f), 0.1f)); + CHECK(Nz::NumberEquals(special.ToEulerAngles().pitch.ToDegrees(), 0.f, 0.1f)); + CHECK(Nz::NumberEquals(special.ToEulerAngles().yaw.ToDegrees(), 1.f, 0.1f)); + CHECK(Nz::NumberEquals(special.ToEulerAngles().roll.ToDegrees(), 90.f, 0.1f)); } } } diff --git a/tests/Engine/Math/Vector2.cpp b/tests/Engine/Math/Vector2.cpp index 45ca1468c..4927656f2 100644 --- a/tests/Engine/Math/Vector2.cpp +++ b/tests/Engine/Math/Vector2.cpp @@ -1,6 +1,6 @@ -#include #include +#include #include SCENARIO("Vector2", "[MATH][VECTOR2]") @@ -27,9 +27,9 @@ SCENARIO("Vector2", "[MATH][VECTOR2]") { REQUIRE(firstUnit.AbsDotProduct(tmp) == Approx(2.f)); REQUIRE(firstUnit.DotProduct(tmp) == Approx(0.f)); - REQUIRE(firstUnit.AngleBetween(tmp) == Approx(Nz::FromDegrees(90.f))); + REQUIRE(firstUnit.AngleBetween(tmp) == Nz::DegreeAnglef(90.f)); Nz::Vector2f negativeUnitX = -Nz::Vector2f::UnitX(); - REQUIRE(negativeUnitX.AngleBetween(negativeUnitX + Nz::Vector2f(0, 0.0000001f)) == Approx(Nz::FromDegrees(360.f))); + REQUIRE(negativeUnitX.AngleBetween(negativeUnitX + Nz::Vector2f(0, 0.0000001f)) == Nz::DegreeAnglef(360.f)); } } diff --git a/tests/Engine/Math/Vector3.cpp b/tests/Engine/Math/Vector3.cpp index faeb03cca..ff1cee85f 100644 --- a/tests/Engine/Math/Vector3.cpp +++ b/tests/Engine/Math/Vector3.cpp @@ -1,7 +1,6 @@ -#include #include - #include +#include #include SCENARIO("Vector3", "[MATH][VECTOR3]") @@ -27,8 +26,8 @@ SCENARIO("Vector3", "[MATH][VECTOR3]") { REQUIRE(firstUnit.AbsDotProduct(tmp) == Approx(2.f)); REQUIRE(firstUnit.DotProduct(tmp) == Approx(0.f)); - REQUIRE(firstUnit.AngleBetween(tmp) == Approx(Nz::FromDegrees(90.f))); - REQUIRE(firstUnit.AngleBetween(-firstUnit) == Approx(Nz::FromDegrees(180.f))); + REQUIRE(firstUnit.AngleBetween(tmp) == Nz::DegreeAnglef(90.f)); + REQUIRE(firstUnit.AngleBetween(-firstUnit) == Nz::DegreeAnglef(180.f)); } } diff --git a/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp b/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp index faf946801..03d354903 100644 --- a/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp +++ b/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp @@ -99,7 +99,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]") CHECK(physicsComponent2D.GetAngularVelocity() == angularSpeed); CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(-2.f, 0.f, 2.f, 1.f)); CHECK(physicsComponent2D.GetRotation() == Nz::RadianAnglef::FromDegrees(90.f)); - CHECK(nodeComponent.GetRotation().ToEulerAngles().roll == Approx(Nz::FromDegrees(90.f))); + CHECK(nodeComponent.GetRotation().ToEulerAngles().roll == Nz::DegreeAnglef(90.f)); } } @@ -147,7 +147,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]") CHECK(physicsComponent2D.GetAABB() == Nz::Rectf(1.f, 4.f, 2.f, 1.f)); CHECK(physicsComponent2D.GetRotation() == 2.f * angularSpeed); CHECK(nodeComponent.GetPosition() == position); - CHECK(nodeComponent.GetRotation().ToEulerAngles().roll == Approx(Nz::FromDegrees(90.f))); + CHECK(nodeComponent.GetRotation().ToEulerAngles().roll == Nz::DegreeAnglef(90.f)); } } }