From fe88e68e733d91727607c6bc079bef04ca056398 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Wed, 27 Feb 2013 23:10:54 +0100 Subject: [PATCH] Improve robustness by using correct machine epsilon value test --- src/engine/ContactSolver.cpp | 4 ++-- src/mathematics/Vector3.cpp | 4 ++-- src/mathematics/Vector3.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/ContactSolver.cpp b/src/engine/ContactSolver.cpp index b0dfa4ac..3e610b26 100644 --- a/src/engine/ContactSolver.cpp +++ b/src/engine/ContactSolver.cpp @@ -848,7 +848,7 @@ void ContactSolver::computeFrictionVectors(const Vector3& deltaVelocity, // If the velocty difference in the tangential plane is not zero decimal lengthTangenVelocity = tangentVelocity.length(); - if (lengthTangenVelocity > 0.0) { + if (lengthTangenVelocity > MACHINE_EPSILON) { // Compute the first friction vector in the direction of the tangent // velocity difference @@ -878,7 +878,7 @@ void ContactSolver::computeFrictionVectors(const Vector3& deltaVelocity, // If the velocty difference in the tangential plane is not zero decimal lengthTangenVelocity = tangentVelocity.length(); - if (lengthTangenVelocity > 0.0) { + if (lengthTangenVelocity > MACHINE_EPSILON) { // Compute the first friction vector in the direction of the tangent // velocity difference diff --git a/src/mathematics/Vector3.cpp b/src/mathematics/Vector3.cpp index 53d91ec7..8df24426 100644 --- a/src/mathematics/Vector3.cpp +++ b/src/mathematics/Vector3.cpp @@ -55,7 +55,7 @@ Vector3::~Vector3() { Vector3 Vector3::getUnit() const { decimal lengthVector = length(); - assert(lengthVector > std::numeric_limits::epsilon()); + assert(lengthVector > MACHINE_EPSILON); // Compute and return the unit vector decimal lengthInv = 1.0 / lengthVector; @@ -65,7 +65,7 @@ Vector3 Vector3::getUnit() const { // Return one unit orthogonal vector of the current vector Vector3 Vector3::getOneUnitOrthogonalVector() const { - assert(length() > std::numeric_limits::epsilon()); + assert(length() > MACHINE_EPSILON); // Get the minimum element of the vector Vector3 vectorAbs(fabs(x), fabs(y), fabs(z)); diff --git a/src/mathematics/Vector3.h b/src/mathematics/Vector3.h index bc640a42..60ca0d81 100644 --- a/src/mathematics/Vector3.h +++ b/src/mathematics/Vector3.h @@ -288,7 +288,7 @@ inline Vector3 operator*(const Vector3& vector, decimal number) { // Overloaded operator for division by a number inline Vector3 operator/(const Vector3& vector, decimal number) { - assert(number > std::numeric_limits::epsilon()); + assert(number > MACHINE_EPSILON); return Vector3(vector.x / number, vector.y / number, vector.z / number); }