Convert eulerAngle to Quaternion over 180 degree, Log Quaternion.EulerAngles.x, y, z, result changed

Hi, guys!

Convert eulerAngle to Quaternion over 180 degree, Log Quaternion.eulerAngles.x, y, z, result changed !

the initialized eulerAngle:
x = 181f;
y = 17.003f;
z = 5.24f;

But Log the converted Quaternion.eulerAngles:

quaternion.eulerAngles.x = 359,
quaternion.eulerAngles.y = 197.003,
quaternion.eulerAngles.z = 185.24,

The degree is different from what i initialized, why?

public class test : MonoBehaviour {
  
    void Start(){

        Quaternion q = Quaternion.Euler (181f, 17.003f, 5.24f);

        Debug.Log ( q.eulerAngles.x );
        Debug.Log ( q.eulerAngles.y );
        Debug.Log ( q.eulerAngles.z );
    }
}

A quaternion represents a rotation that follows the closest path towards the target rotation. Thus, a rotation representing an angle greater than 180 degrees is probably taking the opposite path than expected.

There’s not a “two-way” correspondence among quaternions and euler angles. For example, you may define a 360 degrees rotation with euler angles, or even two complete rounds (720 degrees). But quaternions will take the closest path to the destination, so in both these cases (360 and 720 degrees) the equivalent quaternion would be the identity quaternion (no rotation).