Esempio n. 1
0
        public static double Gamma(double value, double absmax, double gamma)
        {
            bool flag = false;

            if (value < 0.0)
            {
                flag = true;
            }
            double num1 = Mathd.Abs(value);

            if (num1 > absmax)
            {
                if (flag)
                {
                    return(-num1);
                }
                else
                {
                    return(num1);
                }
            }
            else
            {
                double num2 = Mathd.Pow(num1 / absmax, gamma) * absmax;
                if (flag)
                {
                    return(-num2);
                }
                else
                {
                    return(num2);
                }
            }
        }
Esempio n. 2
0
        public static float Gamma(float value, float absmax, float gamma)
        {
            bool flag = false;

            if (value < 0.0)
            {
                flag = true;
            }
            float num1 = Mathd.Abs(value);

            if (num1 > absmax)
            {
                if (flag)
                {
                    return(-num1);
                }
                else
                {
                    return(num1);
                }
            }
            else
            {
                float num2 = Mathd.Pow(num1 / absmax, gamma) * absmax;
                if (flag)
                {
                    return(-num2);
                }
                else
                {
                    return(num2);
                }
            }
        }
Esempio n. 3
0
 public static double MoveTowards(double current, double target, double maxDelta)
 {
     if (Mathd.Abs(target - current) <= maxDelta)
     {
         return(target);
     }
     else
     {
         return(current + Mathd.Sign(target - current) * maxDelta);
     }
 }
Esempio n. 4
0
 public static float MoveTowards(float current, float target, float maxDelta)
 {
     if (Mathd.Abs(target - current) <= maxDelta)
     {
         return(target);
     }
     else
     {
         return(current + Mathd.Sign(target - current) * maxDelta);
     }
 }
Esempio n. 5
0
 public static double PingPong(double t, double length)
 {
     t = Mathd.Repeat(t, length * 2d);
     return(length - Mathd.Abs(t - length));
 }
Esempio n. 6
0
 public static bool Approximately(double a, double b)
 {
     return(Mathd.Abs(b - a) < Mathd.Max(1E-06d * Mathd.Max(Mathd.Abs(a), Mathd.Abs(b)), 1.121039E-44d));
 }
Esempio n. 7
0
 public static float PingPong(float t, float length)
 {
     t = Mathd.Repeat(t, length * 2f);
     return(length - Mathd.Abs(t - length));
 }
Esempio n. 8
0
 public static bool Approximately(float a, float b)
 {
     return(Mathd.Abs(b - a) < Mathd.Max(1E-06f * Mathd.Max(Mathd.Abs(a), Mathd.Abs(b)), 1.121039E-44f));
 }
Esempio n. 9
0
        /*
         * public override string ToString()
         * {
         *      string fmt = "({0:F1}, {1:F1}, {2:F1}, {3:F1})";
         *      object[] objArray = new object[4];
         *      int index1 = 0;
         *      // ISSUE: variable of a boxed type
         *      __Boxed<double> local1 = (ValueType) this.x;
         *      objArray[index1] = (object) local1;
         *      int index2 = 1;
         *      // ISSUE: variable of a boxed type
         *      __Boxed<double> local2 = (ValueType) this.y;
         *      objArray[index2] = (object) local2;
         *      int index3 = 2;
         *      // ISSUE: variable of a boxed type
         *      __Boxed<double> local3 = (ValueType) this.z;
         *      objArray[index3] = (object) local3;
         *      int index4 = 3;
         *      // ISSUE: variable of a boxed type
         *      __Boxed<double> local4 = (ValueType) this.w;
         *      objArray[index4] = (object) local4;
         *      return UnityString.Format(fmt, objArray);
         * }
         *
         * public string ToString(string format)
         * {
         *      string fmt = "({0}, {1}, {2}, {3})";
         *      object[] objArray = new object[4];
         *      int index1 = 0;
         *      string str1 = this.x.ToString(format);
         *      objArray[index1] = (object) str1;
         *      int index2 = 1;
         *      string str2 = this.y.ToString(format);
         *      objArray[index2] = (object) str2;
         *      int index3 = 2;
         *      string str3 = this.z.ToString(format);
         *      objArray[index3] = (object) str3;
         *      int index4 = 3;
         *      string str4 = this.w.ToString(format);
         *      objArray[index4] = (object) str4;
         *      return UnityString.Format(fmt, objArray);
         * }
         */

        public static double Angle(QuaternionD a, QuaternionD b)
        {
            return((double)Mathd.Acos(Mathd.Min(Mathd.Abs(QuaternionD.Dot(a, b)), 1.0)) * 2.0 * 57.2957801818848);
        }
Esempio n. 10
0
 public bool Similar(Vector3d other, double epsilon = EPSILON)
 {
     return(Mathd.Abs(x - other.x) < epsilon && Mathd.Abs(y - other.y) < epsilon && Mathd.Abs(z - other.z) < epsilon);
 }