Value change: Euler to Quaternion then back to Euler

https://playground.babylonjs.com/#1ST43U#665
I have an euler rotation. After I modify it, I translate euler into yprQuaternion2, then I translate yprQuaternion2 into euler2. Why euler and euler2 has different value?

    var euler = box.rotationQuaternion.toEulerAngles()
    console.log(euler)
    euler.x *= -1 
    euler.y += Math.PI*(180/180)
    euler.y += 2*(Math.PI-euler.y)
    euler.z = 0
    var yprQuaternion2 = BABYLON.Quaternion.RotationYawPitchRoll(euler.y, euler.x, euler.z);
    var euler2 = yprQuaternion2.toEulerAngles()
    console.log([euler.x,euler.y,euler.z])
    console.log(euler2)

image Three console.log give three different output. What happens lol

In the 2nd and the 3rd logs, euler and euler2 are probably the same angle but presented differently in values.

4.886921905584122 / (Math.PI * 2) * 360 = 280 degree.
-1.396263401595464 / (Math.PI * 2) * 360 = -80 degree.

1 Like