Search Unity

Quaternion, Euler Angles and Atan2

Discussion in 'Physics' started by jkraptor, Nov 2, 2015.

  1. jkraptor

    jkraptor

    Joined:
    Sep 28, 2013
    Posts:
    24
    I have been working with configurable joints and have needed to read the x,y and z axis rotations.
    To do this, I've been using Quaternion.EulerAngles(), but ran into a problem when going from 275 down to 265 degrees. I found that values less than 270 were returns as > 270.

    Example: 268 --> 272
    260 --> 280

    This problem, I think could be caused by the Unity EulerAngles() using the Atan function instead of Atan2 to calculate the angles from the quaternion compononents. See the article on using Atan2 for conversion. (click here)

    Can anyone confirm that EulerAngles is not able to return angles between 90 and 270?
    I'm still on 5.0.2 due to other joint issues, but did see any mention of this in the IssueTracker or forums.

    Thanks.