This site uses strictly necessary cookies. More Information

X**closed**Apr 01, 2020 at 08:42 AM by Flo_P for the following reason:

The question is answered, right answer was accepted

# Order of the rotations around the axes with Euler angles

According to the documentation, with Euler angles:

rotations are performed around the Z axis, the X axis, and the Y axis, in that order.

When I try to reproduce it in the inspector and with scripts, it seems that the rotation order is "YXZ", and not "ZXY".

Do you know the reason of this behaviour ? If Unity use the "YXZ" order, do you know how to convert the euler angles to "ZXY" ?

You can check the GIF files or the script below:

```
using UnityEngine;
public class RotationTest : MonoBehaviour
{
public Vector3 rotation;
public bool useYXZ = true;
private void Awake()
{
if (useYXZ) ApplyQuaternionYXZ();
else ApplyQuaternionZXY();
Debug.Log(transform.eulerAngles);
}
private void ApplyQuaternionYXZ()
{
transform.RotateAround(transform.position, transform.up, rotation.y);
transform.RotateAround(transform.position, transform.right, rotation.x);
transform.RotateAround(transform.position, transform.forward, rotation.z);
}
private void ApplyQuaternionZXY()
{
transform.RotateAround(transform.position, transform.forward, rotation.z);
transform.RotateAround(transform.position, transform.right, rotation.x);
transform.RotateAround(transform.position, transform.up, rotation.y);
}
}
```

**Answer** by GGsparta
·
Mar 31, 2020 at 05:18 PM

Rotations are performed around the global axis, not local. You can test with the following code:

```
transform.RotateAround(transform.position, Vector3.forward, rotation.z);
transform.RotateAround(transform.position, Vector3.right, rotation.x);
transform.RotateAround(transform.position, Vector3.up, rotation.y);
```

Thank you for your answer ! So if I understand well, the rotation order ZXY with global axes is equivalent to the rotation order YXZ with local axes. Interesting...

The real name of what I called "Zxy" with local axes (or "Yxz" with global axes) is "roll/pitch/yaw" angles.

To calculate it, use this answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Avoiding Gimbal Lock with Vector3 EulerAngles and Applying Torque 0 Answers

transform.rotation spazes out 0 Answers

How to clamp rotation, following Unity's quaternion rules 1 Answer

I can get Quaternion data(x,y,z,w) from simulation program. But, how to assign it in rotation? 1 Answer

Quaternions to EulerAngles weird x-axis interaction 1 Answer