Matrix4f to Quat4f - bug in vecmath ?

Hi I don’t know if this a bug or if it is supposed to be like that. When I execute this code


        Quat4f qStart = new Quat4f(0,0.707f,0.707f,0);
        Matrix4f mStart = new Matrix4f();
        mStart.set(qStart);
        Quat4f qEnd = new Quat4f();
        mStart.get(qEnd);
        Matrix4f mEnd = new Matrix4f();
        mEnd.set(qEnd);
        System.out.println("qStart: "+qStart);
        System.out.println("\nmStart: "+mStart);
        System.out.println("\nqEnd: "+qEnd);
        System.out.println("\nmEnd: "+mEnd);

I get:

qStart: (0.0, 0.7071068, 0.7071068, 0.0)

mStart: -1.0000002, 0.0, 0.0, 0.0
0.0, -1.1920929E-7, 1.0000001, 0.0
0.0, 1.0000001, -1.1920929E-7, 0.0
0.0, 0.0, 0.0, 1.0

qEnd: (NaN, NaN, NaN, NaN)

mEnd: NaN, NaN, NaN, 0.0
NaN, NaN, NaN, 0.0
NaN, NaN, NaN, 0.0
0.0, 0.0, 0.0, 1.0

So it seems, that transforming a Quaternion into Matrix and then this into the Quad back again, is not a identity transformation !!!

We ran into this. I am not sure about a bug or not, but our solution was to use Transform3d. Lots of get and set methods on all kinds of values.
You can set your T3d with a quat and pull the matrix. And vise versa.
I guess it would depend on what your trying to do. But it should work for most situations.

Matt

[edit] spelling

Thanks, this approach works probably well for Java3D users, but I’m actually coming from odejava and they only use the vecmath package, so they don’t have the javax.j3d.media package which contains Transform3D.