Strange quaternion rounding issue...

Hi guys!
I hope you might give me a clue what’s going on here…

I got some really weird x-value rounding happening here, when converting from euler to quaternion and back…

Code:

 Vector3 testVec1 = new Vector3(88, 0, 0);
 Debug.Log("testVec1: Setting rotation to: " + testVec1);
 Debug.Log("testVec1: Set rotation to: " + Quaternion.Euler(testVec1).eulerAngles);

 Vector3 testVec2 = new Vector3(0, 88, 0);
 Debug.Log("testVec2: Setting rotation to: " + testVec2);
 Debug.Log("testVec2: Set rotation to: " + Quaternion.Euler(testVec2).eulerAngles);

Output:

testVec1: Setting rotation to: (88.0, 0.0, 0.0)
testVec1: Set rotation to: (90.0, 0.0, 0.0) // <== !!!  why 90 ?!?!?

testVec2: Setting rotation to: (0.0, 88.0, 0.0)
testVec2: Set rotation to: (0.0, 88.0, 0.0)

Anyone got an idea where this comes from??

I’m not really sure of how the conversion algorithm works, but is this the only time you need this in your code? If it is you could just hardcode -2 xD

The rounding seems a bit excessive, but you ought to avoid going near 90 degrees anyway, and also avoid converting from euler angles to a quaternion and back again - just remember the original euler angles, if you must, or don’t use euler angles at all.