fix for division by zero, in case angular velocity goes close to zero

(but not zero)
This commit is contained in:
Erwin Coumans
2017-05-11 17:45:01 -07:00
parent f74adffb84
commit 424a29474f
2 changed files with 26 additions and 5 deletions

View File

@@ -355,7 +355,15 @@ public:
{
return btSqrt(length2());
}
btQuaternion& safeNormalize()
{
btScalar l2 = length2();
if (l2>SIMD_EPSILON)
{
normalize();
}
return *this;
}
/**@brief Normalize the quaternion
* Such that x^2 + y^2 + z^2 +w^2 = 1 */
btQuaternion& normalize()