Euler and Quaternion convert each other got difference result

why these quaternions have difference result?

var quaternion1 = new Quaternion();

        quaternion1.fromArray([20, 1, 0, 0]);

        var euler4 = new Euler();


        var euler5 = new Euler(euler4.x, euler4.y, euler4.z, 'XYZ');

        var  quaternion2 = new Quaternion();

         quaternion2.setFromEuler(euler5, true);

        console.log( quaternion2.x, quaternion2.y, quaternion2.z, quaternion2.w);

        console.log(quaternion1.x, quaternion1.y, quaternion1.z, quaternion1.w);



-0.6982147981960125, -0.7158883261934794, -4.3835517360990044e-17, 4.275332588640309e-17

20, 1, 0, 0

That is no valid code. The values of a quaternion’s components lie in the range [-1, 1]. Also notice that these values are no angle values in degrees or radians. They are not considered as human readable.

I highly recommend to never setup the components of a quaternion in a manual way. The common ways are:

  • Define a quaternion from euler angles (via setFromEuler()).
  • Define a quaternion via methods like lookAt(), rotateTowards() or setFromAxisAngle().

oh,sorry ,i see .

[20, 1, 0, 0] is from blender

blender quaternions is [w,x,y,z] and three.js is [x,y,z,w]

1 Like