Added check to Quat::makeRotate(,,,) to catch zero lengh axis.

This commit is contained in:
Robert Osfield
2004-06-04 10:05:18 +00:00
parent de52abcdd3
commit c69a8a5b80

View File

@@ -50,7 +50,17 @@ void Quat::get(Matrixd& matrix) const
/// (radians) around the axis (x,y,z)
void Quat::makeRotate( value_type angle, value_type x, value_type y, value_type z )
{
value_type inversenorm = 1.0/sqrt( x*x + y*y + z*z );
const value_type epsilon = 0.0000001;
value_type length = sqrt( x*x + y*y + z*z );
if (length < epsilon)
{
// ~zero length axis, so reset rotation to zero.
*this = Quat();
return;
}
value_type inversenorm = 1.0/length;
value_type coshalfangle = cos( 0.5*angle );
value_type sinhalfangle = sin( 0.5*angle );