Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity.Mathematics.quaternion.Euler vs UnityEngine.Quaternion.Euler

Discussion in 'Entity Component System' started by Reshima, Jan 6, 2019.

  1. Reshima

    Reshima

    Joined:
    Dec 10, 2012
    Posts:
    51
    Sorry if this question is too dumb, but I can't quite understand why the conversion from Euler to Quaternion is returning vastly different results when using Unity.Mathematics:

    Code (CSharp):
    1.  
    2. // returns Quaternion(0.4, 0.3, -0.2, 0.8)
    3. UnityEngine.Quaternion.Euler(50f, 45f, 0f);
    4.  
    5. // returns quaternion(0.1155834, -0.4828888, -0.0644784, -0.865622)
    6. Unity.Mathematics.quaternion.EulerZXY(50f, 45f, 0f);
    The things I can think of is: radians vs degrees (but I believe both uses degrees) and rotation order (which I believe Quaternion.Euler is similar to quaternion.EulerZXY). Thanks in advance.
     
    Last edited: Jan 6, 2019
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    Quaternion.Euler is in degrees.

    Read the description of quaternion.Euler, it's in radians.

    If you think they're in radians why are you passing degrees?

    -edit-

    yeah it's a bit confusing they changed the behavior, but the new math library is very well documented.
     
    Antypodish likes this.
  3. Reshima

    Reshima

    Joined:
    Dec 10, 2012
    Posts:
    51
    Oops thanks, yeah, I wanted to say degrees.Thanks.