Search Unity

eulerAngles/Quaternion precision issue? (not gimbal-lock)

Discussion in 'Scripting' started by Patrick234, Jul 28, 2014.

  1. Patrick234

    Patrick234

    Joined:
    Jun 25, 2014
    Posts:
    88
    Try this:

    Code (CSharp):
    1.  
    2. if(Input.GetButtonDown("Right")){
    3.       transform.rotation*=Quaternion.AngleAxis(22.5f, Vector3.up);
    4.       float angle = transform.rotation.eulerAngles.y;
    5.       Debug.Log("Angle: "+angle);
    6. }
    7.  
    So i thought doing a clean Quaternion would give a clean eulerAngles to read from for a 360 value, however, i noticed anything from 0 to 90 range gives an ever increasing precision issue. (Example: 0 value should be 0? but it is 1.807988E-05 which is ridicelous. Its off by a whole 1.8!)

    This breaks my code.

    I dont think its right to have a precision fault in something like this.Is this a bug?

    I also found another post adressing this:
    http://answers.unity3d.com/questions/244418/eulerangle-problem.html
     
    Last edited: Jul 28, 2014
  2. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    No... It's off by 0.0000018, which falls into the float imprecision range. It's not breaking your code, and if it is, your code is wrong.
     
  3. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    1.8

    *chuckle*
     
  4. Patrick234

    Patrick234

    Joined:
    Jun 25, 2014
    Posts:
    88
  5. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    I need a picture of what you are?

    *chuckle*