Issue reading rotations?

Hi guys,

I am trying to find out whether there is a bug in JME3 or if I simply doing things wrong. I am trying to rotate a node every tick and then read out the orientation

Rotating the node:

float[] angles = new float[3];
angles[0] = (float) Math.toRadians(0);
angles[1] = (float) Math.toRadians(0);
angles[2] = (float) Math.toRadians(10);

Quaternion rot = new Quaternion(angles);
node.rotate(rot);

Reading the orientation:

float[] anglesOut = new float[3];
node.getLocalRotation().toAngles(anglesOut);
System.out.println(angles[2]);

When I let it run in the same rotation direction I see that a full 0-360 degree rotation is shown as 0 to 1.57 then from 1.57 to 0 (positive) then from 0 to -1.57 and then from -1.57 back to 0. I would expect the range to be 0 to 3.14 then 3.14 to 2*3.14 or alternatively, 0 to 3.14 then -3.14 to 0
Any thoughts on this? Thanks!

You should maybe read more about quaternions and the different between those and Euler angles.

You can throw any random old crap in an Euler angle 13586723948659283476,276913847569183476,912345691345 … obviously you can’t expect to get that back out of a Quaternion because a Quaternion is a compact and unambiguous version of the rotation.

So the behavior you see is absolutely expected and is one of the benefits of Quaternions. However, if you need your original input Euler angle set then you will have to keep them separately.

I have been reading about these euler/quaternions differences, but I just wanted to make sure this was the case and not something else… Thanks!