MatrixF::toEuler Bug (and fix)
by William Todd Scott · in Torque Game Engine Advanced · 12/28/2006 (1:12 pm) · 1 replies
Hi,
I believe that the following bug is caused by floating point errors.
Basically, in the MatrixF::toEuler() function it is possible for the following line to return a NaN if the value of idx(2,1) is greater than 1.0 or less than -1.0. This was happening quite frequently where I was getting values like 1.00001.
The fix is to simply clamp the value to the -1.0 to 1.0 range:
Todd
I believe that the following bug is caused by floating point errors.
Basically, in the MatrixF::toEuler() function it is possible for the following line to return a NaN if the value of idx(2,1) is greater than 1.0 or less than -1.0. This was happening quite frequently where I was getting values like 1.00001.
r.x = mAsin(mat[MatrixF::idx(2,1)])
The fix is to simply clamp the value to the -1.0 to 1.0 range:
r.x = mAsin(mClampF(mat[MatrixF::idx(2,1)], -1.0f, 1.0f)); //fix
Todd
Associate Kyle Carter
Thanks for writing this up, much appreciated.