Improve robustness by using correct machine epsilon value test

This commit is contained in:
Daniel Chappuis 2013-02-27 23:10:54 +01:00
parent cdc384db68
commit fe88e68e73
3 changed files with 5 additions and 5 deletions

View File

@ -848,7 +848,7 @@ void ContactSolver::computeFrictionVectors(const Vector3& deltaVelocity,
// If the velocty difference in the tangential plane is not zero // If the velocty difference in the tangential plane is not zero
decimal lengthTangenVelocity = tangentVelocity.length(); decimal lengthTangenVelocity = tangentVelocity.length();
if (lengthTangenVelocity > 0.0) { if (lengthTangenVelocity > MACHINE_EPSILON) {
// Compute the first friction vector in the direction of the tangent // Compute the first friction vector in the direction of the tangent
// velocity difference // velocity difference
@ -878,7 +878,7 @@ void ContactSolver::computeFrictionVectors(const Vector3& deltaVelocity,
// If the velocty difference in the tangential plane is not zero // If the velocty difference in the tangential plane is not zero
decimal lengthTangenVelocity = tangentVelocity.length(); decimal lengthTangenVelocity = tangentVelocity.length();
if (lengthTangenVelocity > 0.0) { if (lengthTangenVelocity > MACHINE_EPSILON) {
// Compute the first friction vector in the direction of the tangent // Compute the first friction vector in the direction of the tangent
// velocity difference // velocity difference

View File

@ -55,7 +55,7 @@ Vector3::~Vector3() {
Vector3 Vector3::getUnit() const { Vector3 Vector3::getUnit() const {
decimal lengthVector = length(); decimal lengthVector = length();
assert(lengthVector > std::numeric_limits<decimal>::epsilon()); assert(lengthVector > MACHINE_EPSILON);
// Compute and return the unit vector // Compute and return the unit vector
decimal lengthInv = 1.0 / lengthVector; decimal lengthInv = 1.0 / lengthVector;
@ -65,7 +65,7 @@ Vector3 Vector3::getUnit() const {
// Return one unit orthogonal vector of the current vector // Return one unit orthogonal vector of the current vector
Vector3 Vector3::getOneUnitOrthogonalVector() const { Vector3 Vector3::getOneUnitOrthogonalVector() const {
assert(length() > std::numeric_limits<decimal>::epsilon()); assert(length() > MACHINE_EPSILON);
// Get the minimum element of the vector // Get the minimum element of the vector
Vector3 vectorAbs(fabs(x), fabs(y), fabs(z)); Vector3 vectorAbs(fabs(x), fabs(y), fabs(z));

View File

@ -288,7 +288,7 @@ inline Vector3 operator*(const Vector3& vector, decimal number) {
// Overloaded operator for division by a number // Overloaded operator for division by a number
inline Vector3 operator/(const Vector3& vector, decimal number) { inline Vector3 operator/(const Vector3& vector, decimal number) {
assert(number > std::numeric_limits<decimal>::epsilon()); assert(number > MACHINE_EPSILON);
return Vector3(vector.x / number, vector.y / number, vector.z / number); return Vector3(vector.x / number, vector.y / number, vector.z / number);
} }