diff --git a/include/zeus/CVector3f.hpp b/include/zeus/CVector3f.hpp index 2a0413d..1f962e9 100644 --- a/include/zeus/CVector3f.hpp +++ b/include/zeus/CVector3f.hpp @@ -152,12 +152,12 @@ public: static CVector3f slerp(const CVector3f& a, const CVector3f& b, CRelAngle clampAngle); - bool isNormalized() const { return std::fabs(1.f - magSquared()) < 0.01f; } + bool isNormalized() const { return std::fabs(1.f - magSquared()) <= FLT_EPSILON; } bool canBeNormalized() const { if (std::isinf(x()) || std::isinf(y()) || std::isinf(z())) return false; - return std::fabs(x()) >= FLT_EPSILON || std::fabs(y()) >= FLT_EPSILON || std::fabs(z()) >= FLT_EPSILON; + return !(std::fabs(x()) < FLT_EPSILON && std::fabs(y()) < FLT_EPSILON && std::fabs(z()) < FLT_EPSILON); } bool isZero() const { return magSquared() <= FLT_EPSILON; } diff --git a/include/zeus/Math.hpp b/include/zeus/Math.hpp index 3c1ffc3..f042876 100644 --- a/include/zeus/Math.hpp +++ b/include/zeus/Math.hpp @@ -157,15 +157,15 @@ typename std::enable_if::value, int>::type PopCount(E e) { return PopCount(static_cast::type>(e)); } -bool close_enough(const CVector3f& a, const CVector3f& b, float epsilon = 0.000099999997f); +bool close_enough(const CVector3f& a, const CVector3f& b, float epsilon = FLT_EPSILON); -bool close_enough(const CVector2f& a, const CVector2f& b, float epsilon = 0.000099999997f); +bool close_enough(const CVector2f& a, const CVector2f& b, float epsilon = FLT_EPSILON); -inline bool close_enough(float a, float b, double epsilon = 0.000009999999747378752) { +inline bool close_enough(float a, float b, double epsilon = FLT_EPSILON) { return std::fabs(a - b) < epsilon; } -inline bool close_enough(double a, double b, double epsilon = 0.000009999999747378752) { +inline bool close_enough(double a, double b, double epsilon = FLT_EPSILON) { return std::fabs(a - b) < epsilon; } } // namespace zeus