While debugging a problem with my home-grown 3DS loader, I found
something (wrong?) with going from AxisAngle to Matrix to Quats.

3DS format stores rotations in AxisAngle format.  I use these to load a
Matrix so I can "sum-up" rotations (using matrix multiplies of course).
Then, I set a Quat with the Matrix since the TCB interpolators take
Quats.  After getting some Quats set to (NaN, NaN, NaN, NaN), I did some
playing and got some example code to replicate the problem.

This example code creates an AxisAngle4f to perform 90deg rotation about
the Z axis.  I then create two Matrix4f objects with this same AxisAngle
object, and then multiply the matrices together to get a Matrix4f that
should do a 180deg Z-rotation.

Using this final matrix to set a Quat4f gives me the NaN result.  If I
use AxisAngle4d instead of AxisAngle4f and remove the (float) typecast
in front of the Math.PI*0.5, the example code works.

The code is attached.  Here's the output:

mat1=
-4.371139E-8, -1.0, 0.0, 0.0
1.0, -4.371139E-8, 0.0, 0.0
0.0, 0.0, 0.99999994, 0.0
0.0, 0.0, 0.0, 1.0

mat2=
-4.371139E-8, -1.0, 0.0, 0.0
1.0, -4.371139E-8, 0.0, 0.0
0.0, 0.0, 0.99999994, 0.0
0.0, 0.0, 0.0, 1.0

mat1 * mat2=
-1.0, 8.742278E-8, 0.0, 0.0
-8.742278E-8, -1.0, 0.0, 0.0
0.0, 0.0, 0.9999999, 0.0
0.0, 0.0, 0.0, 1.0

quat=(NaN, NaN, NaN, NaN)

J. Lee Dixon
SAIC - Celebration, FL
321-939-7917
[EMAIL PROTECTED]    AOL: LeeOrlando

QuatTest.java

Reply via email to