Abs() public static méthode

public static Abs ( Fix value ) : Fix
value Fix
Résultat Fix
        //https://math.stackexchange.com/questions/2975109/how-to-convert-euler-angles-to-quaternions-and-get-the-same-euler-angles-back-fr
        public static FixVec3 ToEuler(FixQuaternion q)
        {
            FixVec3 result;

            Fix t0 = 2 * (q.w * q.z + q.x * q.y);
            Fix t1 = 1 - 2 * (q.y * q.y + q.z * q.z);

            result.z = FixMath.Atan2(t0, t1);

            Fix t2 = 2 * (q.w * q.y - q.z * q.x);

            if (FixMath.Abs(t2) >= Fix.one)
            {
                result.y = FixMath.PI / 2;
                //t2 = 1;
            }
            else if (t2 <= -Fix.one)
            {
                result.y = -(FixMath.PI / 2);
                //t2 = -1;
            }
            else
            {
                result.y = FixMath.Asin(t2);
            }

            Fix t3 = 2 * (q.w * q.x + q.y * q.z);
            Fix t4 = 1 - 2 * (q.x * q.x + q.y * q.y);

            result.x = FixMath.Atan2(t3, t4);
            return(result);
        }
Exemple #2
0
 public static FixVec2 Abs(FixVec2 v)
 {
     return(new FixVec2(FixMath.Abs(v.x), FixMath.Abs(v.y)));
 }