Exemplo n.º 1
0
    public static Matrix4x4G Slerp(double t, Matrix4x4G a, Matrix4x4G b)
    {
        Matrix4x4G  identity = Matrix4x4G.identity;
        Vector3G    dotB     = Slerp(t, DIR_X(a), DIR_X(b));
        Vector3G    up       = Slerp(t, DIR_Y(a), DIR_Y(b));
        Vector3G    forward  = Slerp(t, DIR_Z(a), DIR_Z(b));
        QuaternionG rotation = LookRotation(forward, up);

        up = Rotate(rotation, Y3(Length(up)));
        if (CrossDot(forward, up, dotB) > 0.0)
        {
            dotB = Rotate(rotation, X3(-Length(dotB)));
        }
        else
        {
            dotB = Rotate(rotation, X3(Length(dotB)));
        }
        DIR_X(ref identity, dotB);
        DIR_Y(ref identity, up);
        DIR_Z(ref identity, forward);
        SCALE(ref identity, Linear(t, SCALE(a), SCALE(b)));
        TRANS(ref identity, Linear(t, TRANS(a), TRANS(b)));
        identity.m33 = Linear(t, a.m33, b.m33);
        return(identity);
    }
Exemplo n.º 2
0
    public static Vector3G Rotate(QuaternionG rotation, Vector3G vector)
    {
        Vector3G vectorg;

        QuaternionG.Mult(ref rotation, ref vector, out vectorg);
        return(vectorg);
    }
Exemplo n.º 3
0
    public static QuaternionG LookRotation(Vector3G forward, Vector3G up)
    {
        QuaternionG ng;

        QuaternionG.LookRotation(ref forward, ref up, out ng);
        return(ng);
    }
Exemplo n.º 4
0
    private void OnGUI()
    {
        Vector3G vector3G;

        if (Event.current.type != EventType.Repaint)
        {
            return;
        }
        if (this.contents == null)
        {
            this.Awake();
        }
        if (this.lastUnity != this.unity || this.nonHomogenous != this.nonHomogenousWas)
        {
            int num = 0;
            for (int i = 0; i < 4; i++)
            {
                GUIContent str  = this.contents[num, i];
                float      item = this.unity[i];
                str.text = item.ToString("0.######");
            }
            num = 1;
            for (int j = 0; j < 4; j++)
            {
                GUIContent gUIContent = this.contents[num, j];
                double     item1      = this.facep[j];
                gUIContent.text = item1.ToString("0.######");
            }
            num = 2;
            if (!this.nonHomogenous)
            {
                QuaternionG.ToEuler(ref this.facep, out vector3G);
            }
            else
            {
                QuaternionG.ToEulerNonHomogenious(ref this.facep, out vector3G);
            }
            for (int k = 1; k < 4; k++)
            {
                GUIContent str1 = this.contents[num, k];
                double     num1 = vector3G[k - 1];
                str1.text = num1.ToString("0.######");
            }
            this.nonHomogenousWas = this.nonHomogenous;
            this.lastUnity        = this.unity;
        }
        GUIStyle gUIStyle = GUI.skin.textField;

        for (int l = 0; l < 3; l++)
        {
            for (int m = 0; m < 4; m++)
            {
                GUI.Label(this.rects[l, m], this.contents[l, m], gUIStyle);
            }
        }
    }
Exemplo n.º 5
0
    public static QuaternionG Sum(QuaternionG a, QuaternionG b)
    {
        QuaternionG ng;

        ng.x = a.x + b.x;
        ng.y = a.y + b.y;
        ng.z = a.z + b.z;
        ng.w = a.w * b.w;
        return(ng);
    }
Exemplo n.º 6
0
    public static QuaternionG Mul(QuaternionG a, double b)
    {
        QuaternionG ng;

        ng.x = a.x * b;
        ng.y = a.y * b;
        ng.z = a.z * b;
        ng.w = a.w * b;
        return(ng);
    }
Exemplo n.º 7
0
    // Token: 0x06003DED RID: 15853 RVA: 0x000DFB48 File Offset: 0x000DDD48
    private void OnGUI()
    {
        if (Event.current.type != 7)
        {
            return;
        }
        if (this.contents == null)
        {
            this.Awake();
        }
        if (this.lastUnity != this.unity || this.nonHomogenous != this.nonHomogenousWas)
        {
            int num = 0;
            for (int i = 0; i < 4; i++)
            {
                this.contents[num, i].text = this.unity[i].ToString("0.######");
            }
            num = 1;
            for (int j = 0; j < 4; j++)
            {
                this.contents[num, j].text = this.facep[j].ToString("0.######");
            }
            num = 2;
            Vector3G vector3G;
            if (this.nonHomogenous)
            {
                QuaternionG.ToEulerNonHomogenious(ref this.facep, ref vector3G);
            }
            else
            {
                QuaternionG.ToEuler(ref this.facep, ref vector3G);
            }
            for (int k = 1; k < 4; k++)
            {
                this.contents[num, k].text = vector3G[k - 1].ToString("0.######");
            }
            this.nonHomogenousWas = this.nonHomogenous;
            this.lastUnity        = this.unity;
        }
        GUIStyle textField = GUI.skin.textField;

        for (int l = 0; l < 3; l++)
        {
            for (int m = 0; m < 4; m++)
            {
                GUI.Label(this.rects[l, m], this.contents[l, m], textField);
            }
        }
    }
Exemplo n.º 8
0
 private void OnGUI()
 {
     if (Event.current.type == EventType.Repaint)
     {
         if (this.contents == null)
         {
             this.Awake();
         }
         if ((this.lastUnity != this.unity) || (this.nonHomogenous != this.nonHomogenousWas))
         {
             Vector3G vectorg;
             int      num = 0;
             for (int j = 0; j < 4; j++)
             {
                 this.contents[num, j].text = this.unity[j].ToString("0.######");
             }
             num = 1;
             for (int k = 0; k < 4; k++)
             {
                 this.contents[num, k].text = this.facep[k].ToString("0.######");
             }
             num = 2;
             if (this.nonHomogenous)
             {
                 QuaternionG.ToEulerNonHomogenious(ref this.facep, out vectorg);
             }
             else
             {
                 QuaternionG.ToEuler(ref this.facep, out vectorg);
             }
             for (int m = 1; m < 4; m++)
             {
                 this.contents[num, m].text = vectorg[m - 1].ToString("0.######");
             }
             this.nonHomogenousWas = this.nonHomogenous;
             this.lastUnity        = this.unity;
         }
         GUIStyle textField = GUI.skin.textField;
         for (int i = 0; i < 3; i++)
         {
             for (int n = 0; n < 4; n++)
             {
                 GUI.Label(this.rects[i, n], this.contents[i, n], textField);
             }
         }
     }
 }
Exemplo n.º 9
0
 private void Update()
 {
     if ((this.R == null) || (this.R.Length == 0))
     {
         this.unity = Quaternion.identity;
         this.facep = QuaternionG.identity;
     }
     else if (this.revMul)
     {
         int index = this.R.Length - 1;
         this.unity = Quaternion.Euler(this.R[index]);
         Vector3G deg = new Vector3G(this.R[index]);
         QuaternionG.Euler(ref deg, out this.facep);
         index--;
         while (index >= 0)
         {
             QuaternionG ng;
             this.unity = Quaternion.Euler(this.R[index]) * this.unity;
             deg.f      = this.R[index];
             QuaternionG.Euler(ref deg, out ng);
             QuaternionG.Mult(ref ng, ref this.facep, out this.facep);
             index--;
         }
     }
     else
     {
         int num2 = 0;
         this.unity = Quaternion.Euler(this.R[num2]);
         Vector3G vectorg2 = new Vector3G(this.R[num2]);
         QuaternionG.Euler(ref vectorg2, out this.facep);
         num2++;
         while (num2 < this.R.Length)
         {
             QuaternionG ng2;
             this.unity *= Quaternion.Euler(this.R[num2]);
             vectorg2.f  = this.R[num2];
             QuaternionG.Euler(ref vectorg2, out ng2);
             QuaternionG.Mult(ref this.facep, ref ng2, out this.facep);
             num2++;
         }
     }
 }
Exemplo n.º 10
0
 // Token: 0x06003DEB RID: 15851 RVA: 0x000DF8D0 File Offset: 0x000DDAD0
 private void Update()
 {
     if (this.R == null || this.R.Length == 0)
     {
         this.unity = Quaternion.identity;
         this.facep = QuaternionG.identity;
     }
     else if (this.revMul)
     {
         int i = this.R.Length - 1;
         this.unity = Quaternion.Euler(this.R[i]);
         Vector3G vector3G;
         vector3G..ctor(this.R[i]);
         QuaternionG.Euler(ref vector3G, ref this.facep);
         for (i--; i >= 0; i--)
         {
             this.unity = Quaternion.Euler(this.R[i]) * this.unity;
             vector3G.f = this.R[i];
             QuaternionG quaternionG;
             QuaternionG.Euler(ref vector3G, ref quaternionG);
             QuaternionG.Mult(ref quaternionG, ref this.facep, ref this.facep);
         }
     }
     else
     {
         int j = 0;
         this.unity = Quaternion.Euler(this.R[j]);
         Vector3G vector3G2;
         vector3G2..ctor(this.R[j]);
         QuaternionG.Euler(ref vector3G2, ref this.facep);
         for (j++; j < this.R.Length; j++)
         {
             this.unity *= Quaternion.Euler(this.R[j]);
             vector3G2.f = this.R[j];
             QuaternionG quaternionG2;
             QuaternionG.Euler(ref vector3G2, ref quaternionG2);
             QuaternionG quaternionG3 = this.facep;
             QuaternionG.Mult(ref quaternionG3, ref quaternionG2, ref this.facep);
         }
     }
 }
Exemplo n.º 11
0
    private void Update()
    {
        QuaternionG quaternionG;
        QuaternionG quaternionG1;

        if (this.R == null || (int)this.R.Length == 0)
        {
            this.unity = Quaternion.identity;
            this.facep = QuaternionG.identity;
        }
        else if (!this.revMul)
        {
            int i = 0;
            this.unity = Quaternion.Euler(this.R[i]);
            Vector3G vector3G = new Vector3G(this.R[i]);
            QuaternionG.Euler(ref vector3G, out this.facep);
            for (i++; i < (int)this.R.Length; i++)
            {
                QuaternionTest quaternionTest = this;
                quaternionTest.unity = quaternionTest.unity * Quaternion.Euler(this.R[i]);
                vector3G.f           = this.R[i];
                QuaternionG.Euler(ref vector3G, out quaternionG1);
                QuaternionG quaternionG2 = this.facep;
                QuaternionG.Mult(ref quaternionG2, ref quaternionG1, out this.facep);
            }
        }
        else
        {
            int length = (int)this.R.Length - 1;
            this.unity = Quaternion.Euler(this.R[length]);
            Vector3G r = new Vector3G(this.R[length]);
            QuaternionG.Euler(ref r, out this.facep);
            for (length--; length >= 0; length--)
            {
                this.unity = Quaternion.Euler(this.R[length]) * this.unity;
                r.f        = this.R[length];
                QuaternionG.Euler(ref r, out quaternionG);
                QuaternionG.Mult(ref quaternionG, ref this.facep, out this.facep);
            }
        }
    }
Exemplo n.º 12
0
    public static QuaternionG Evaluate(this TransitionFunction f, double t, QuaternionG a, QuaternionG b)
    {
        switch (f)
        {
        case TransitionFunction.Linear:
            return(Linear(t, a, b));

        case TransitionFunction.Round:
            return(Round(t, a, b));

        case TransitionFunction.Floor:
            return(Floor(t, a, b));

        case TransitionFunction.Ceil:
            return(Ceil(t, a, b));

        case TransitionFunction.Spline:
            return(Spline(t, a, b));
        }
        throw new ArgumentOutOfRangeException("v", "Attempted use of unrecognized TransitionFunction enum value");
    }
Exemplo n.º 13
0
 public static QuaternionG Linear(double t, QuaternionG a, QuaternionG b)
 {
     return TransitionFunctions.Slerp(t, a, b);
 }
Exemplo n.º 14
0
 public static QuaternionG Floor(double t, QuaternionG a, QuaternionG b)
 {
     return (t >= 1 ? b : a);
 }
Exemplo n.º 15
0
 public static QuaternionG Evaluate(this TransitionFunction f, double t, QuaternionG a, QuaternionG b)
 {
     switch (f)
     {
         case TransitionFunction.Linear:
         {
             return TransitionFunctions.Linear(t, a, b);
         }
         case TransitionFunction.Round:
         {
             return TransitionFunctions.Round(t, a, b);
         }
         case TransitionFunction.Floor:
         {
             return TransitionFunctions.Floor(t, a, b);
         }
         case TransitionFunction.Ceil:
         {
             return TransitionFunctions.Ceil(t, a, b);
         }
         case TransitionFunction.Spline:
         {
             return TransitionFunctions.Spline(t, a, b);
         }
     }
     throw new ArgumentOutOfRangeException("v", "Attempted use of unrecognized TransitionFunction enum value");
 }
Exemplo n.º 16
0
 public static QuaternionG Sum(QuaternionG a, QuaternionG b)
 {
     QuaternionG quaternionG = new QuaternionG();
     quaternionG.x = a.x + b.x;
     quaternionG.y = a.y + b.y;
     quaternionG.z = a.z + b.z;
     quaternionG.w = a.w * b.w;
     return quaternionG;
 }
Exemplo n.º 17
0
 public static QuaternionG Spline(double t, QuaternionG a, QuaternionG b)
 {
     QuaternionG quaternionG;
     if (t > 0)
     {
         quaternionG = (t < 1 ? TransitionFunctions.Linear(TransitionFunctions.SimpleSpline(t), a, b) : b);
     }
     else
     {
         quaternionG = a;
     }
     return quaternionG;
 }
Exemplo n.º 18
0
 public static QuaternionG Ceil(double t, QuaternionG a, QuaternionG b)
 {
     return (t <= 0 ? a : b);
 }
Exemplo n.º 19
0
 public static QuaternionG Linear(double t, QuaternionG a, QuaternionG b)
 {
     return(Slerp(t, a, b));
 }
Exemplo n.º 20
0
 public static QuaternionG Round(double t, QuaternionG a, QuaternionG b)
 {
     return (t >= 0.5 ? b : a);
 }
Exemplo n.º 21
0
 public static QuaternionG Ceil(double t, QuaternionG a, QuaternionG b)
 {
     return((t <= 0.0) ? a : b);
 }
Exemplo n.º 22
0
 public static QuaternionG Round(double t, QuaternionG a, QuaternionG b)
 {
     return((t >= 0.5) ? b : a);
 }
Exemplo n.º 23
0
    public static QuaternionG Slerp(double t, QuaternionG a, QuaternionG b)
    {
        QuaternionG ng;
        double      num2;
        double      num3;
        double      num4;

        if (t == 0.0)
        {
            return(a);
        }
        if (t == 1.0)
        {
            return(b);
        }
        double v = (((a.x * b.x) + (a.y * b.y)) + (a.z * b.z)) + (a.w * b.w);

        if (v == 1.0)
        {
            return(a);
        }
        if (v < 0.0)
        {
            v    = Acos(-v);
            num4 = Sin(v);
            if (num4 == 0.0)
            {
                num2 = 1.0 - t;
                ng.x = (a.x * num2) + (b.x * t);
                ng.y = (a.y * num2) + (b.y * t);
                ng.z = (a.z * num2) + (b.z * t);
                ng.w = (a.w * num2) + (b.w * t);
                return(ng);
            }
            num3 = Sin((double)(v * t));
            num2 = Sin((double)(v * (1.0 - t)));
            ng.x = ((a.x * num2) - (b.x * num3)) / num4;
            ng.y = ((a.y * num2) - (b.y * num3)) / num4;
            ng.z = ((a.z * num2) - (b.z * num3)) / num4;
            ng.w = ((a.w * num2) - (b.w * num3)) / num4;
            return(ng);
        }
        v    = Acos(v);
        num4 = Sin(v);
        if (num4 == 0.0)
        {
            num2 = 1.0 - t;
            ng.x = (a.x * num2) + (b.x * t);
            ng.y = (a.y * num2) + (b.y * t);
            ng.z = (a.z * num2) + (b.z * t);
            ng.w = (a.w * num2) + (b.w * t);
            return(ng);
        }
        num3 = Sin((double)(v * t));
        num2 = Sin((double)(v * (1.0 - t)));
        ng.x = ((a.x * num2) + (b.x * num3)) / num4;
        ng.y = ((a.y * num2) + (b.y * num3)) / num4;
        ng.z = ((a.z * num2) + (b.z * num3)) / num4;
        ng.w = ((a.w * num2) + (b.w * num3)) / num4;
        return(ng);
    }
Exemplo n.º 24
0
 public static QuaternionG Spline(double t, QuaternionG a, QuaternionG b)
 {
     return((t > 0.0) ? ((t < 1.0) ? Linear(SimpleSpline(t), a, b) : b) : a);
 }
Exemplo n.º 25
0
 public static QuaternionG Mul(QuaternionG a, double b)
 {
     QuaternionG quaternionG = new QuaternionG();
     quaternionG.x = a.x * b;
     quaternionG.y = a.y * b;
     quaternionG.z = a.z * b;
     quaternionG.w = a.w * b;
     return quaternionG;
 }
Exemplo n.º 26
0
 public static QuaternionG Slerp(double t, QuaternionG a, QuaternionG b)
 {
     QuaternionG quaternionG = new QuaternionG();
     double num;
     double num1;
     double num2;
     if (t == 0)
     {
         quaternionG = a;
     }
     else if (t != 1)
     {
         double num3 = (double)a.x * b.x + (double)a.y * b.y + (double)a.z * b.z + (double)a.w * b.w;
         if (num3 == 1)
         {
             quaternionG = a;
         }
         else if (num3 >= 0)
         {
             num3 = TransitionFunctions.Acos(num3);
             num2 = TransitionFunctions.Sin(num3);
             if (num2 != 0)
             {
                 num1 = TransitionFunctions.Sin(num3 * t);
                 num = TransitionFunctions.Sin(num3 * (1 - t));
                 quaternionG.x = (double)((a.x * num + b.x * num1) / num2);
                 quaternionG.y = (double)((a.y * num + b.y * num1) / num2);
                 quaternionG.z = (double)((a.z * num + b.z * num1) / num2);
                 quaternionG.w = (double)((a.w * num + b.w * num1) / num2);
             }
             else
             {
                 num = 1 - t;
                 quaternionG.x = (double)(a.x * num + b.x * t);
                 quaternionG.y = (double)(a.y * num + b.y * t);
                 quaternionG.z = (double)(a.z * num + b.z * t);
                 quaternionG.w = (double)(a.w * num + b.w * t);
             }
         }
         else
         {
             num3 = TransitionFunctions.Acos(-num3);
             num2 = TransitionFunctions.Sin(num3);
             if (num2 != 0)
             {
                 num1 = TransitionFunctions.Sin(num3 * t);
                 num = TransitionFunctions.Sin(num3 * (1 - t));
                 quaternionG.x = (double)((a.x * num - b.x * num1) / num2);
                 quaternionG.y = (double)((a.y * num - b.y * num1) / num2);
                 quaternionG.z = (double)((a.z * num - b.z * num1) / num2);
                 quaternionG.w = (double)((a.w * num - b.w * num1) / num2);
             }
             else
             {
                 num = 1 - t;
                 quaternionG.x = (double)(a.x * num + b.x * t);
                 quaternionG.y = (double)(a.y * num + b.y * t);
                 quaternionG.z = (double)(a.z * num + b.z * t);
                 quaternionG.w = (double)(a.w * num + b.w * t);
             }
         }
     }
     else
     {
         quaternionG = b;
     }
     return quaternionG;
 }
Exemplo n.º 27
0
 public static Vector3G Rotate(QuaternionG rotation, Vector3G vector)
 {
     Vector3G vector3G;
     QuaternionG.Mult(ref rotation, ref vector, out vector3G);
     return vector3G;
 }
Exemplo n.º 28
0
 public static QuaternionG Floor(double t, QuaternionG a, QuaternionG b)
 {
     return((t >= 1.0) ? b : a);
 }