# Quaternion rotation and -1.#ind

## Recommended Posts

Hello, im rotating an object using quartionions and then converting back to angle axis. A prooblem arises when the object makes any full rotation on one axis it disapears for a frame and then comes back. So i traced scale when this disapearing occurs it has the value -1.#ind. I know this is the problem but i dont kow what this means or how to fix it. Thanks for nay help. here is my code
 float  scale = sqrt(1 - ( qm.mData[3] * qm.mData[3] ) );     //quaternion to axis to angle converion

if (scale == 0 )
scale = 1;

cout <<"scale = " << scale <<endl;

x  = (qm.mData[0] / scale);
y  = ( qm.mData[1] / scale);
z  =  (qm.mData[2] / scale);                         //quaternion to axis to angle converion

float angleq;

angleq = acos( qm.mData[3] ) * 2.0f;                 //quaternion to axis to angle converion



##### Share on other sites
Well, run through it in the debugger and see where the value's coming from. My money's on you trying to find the square root of a negative number.

##### Share on other sites
If qm.mData[3] is greater than 1 or less than -1, even by the tiniest amount, both the sqrt and acos function calls will fail.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627660
• Total Posts
2978489

• 10
• 12
• 22
• 13
• 33