Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Apr 01, 2020 at 08:42 AM by Flo_P for the following reason:

The question is answered, right answer was accepted

avatar image
2
Question by Flo_P · Mar 31, 2020 at 04:30 PM · quaterniondocumentationeuler angles

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);
     }
 }

Example of YXZ Example of ZXY

yxz.gif (464.4 kB)
zxy.gif (491.9 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
2
Best Answer

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);
Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Flo_P · Mar 31, 2020 at 05:34 PM 1
Share

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...

avatar image DeepDeepWoe Flo_P · Sep 11, 2021 at 08:20 PM 0
Share

Hello Flo! I'm encountering the same problem as you. the equivalence of global ZXY and local YXZ is really interesting. Is there a mathematical proof for it?

avatar image Flo_P DeepDeepWoe · Sep 12, 2021 at 04:36 AM 0
Share

Hi ! Nice to see that the question is useful for you

Currently you can consider it as an empirical result.

I suppose it may be proven by constructing the quaternions representing the two ways of rotating the axes, and by checking that they are equals.

Show more comments
avatar image Flo_P · Apr 01, 2020 at 08:41 AM 0
Share

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

Follow this Question

Answers Answers and Comments

202 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Mirror rotation of object along 2 Euler Axis' 0 Answers

Why Quaternion from inverted Euler angles not equal to inverted Quaternion from original Euler? 1 Answer

Annoying Quaternions and Eulers 1 Answer

Avoiding Gimbal Lock with Vector3 EulerAngles and Applying Torque 0 Answers

transform.rotation spazes out 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges