Strange behaviour of quaternions

Could someone run this piece of code and tell me what is wrong?


public static void main(String[] args) {

float[] angles = new float[] {-FastMath.HALF_PI, FastMath.PI, FastMath.HALF_PI};

Quaternion q = new Quaternion(angles);






I get the following results:

[-1.5707964, 3.1415927, 1.5707964]

(0.50000006, 0.50000006, 0.5, 0.5)

[0.0, 1.5707965, 1.5707964]

i confirm i get the same results. I don’t know enough of the details, but i will say it looks a bit strange that toAngles() doesn’t return the same initial values.

That it doesn’t return the same values is actually normal. Whether or not it is returning incorrect values is another question entirely.

I believe the sets of euler angles are actually equivalent but my brain has trouble working after the second rotation. Combining multiple 180 and 90 degree rotations is likely to produce some kind of gimbal lock, though.

Another good test would be to see if feeding them back into another quaternion produces the same quaternion…

Is there a techy Blender forum where such questions might be asked?