Example #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);
                }
            }
        }
Example #2
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);
     }
 }
Example #3
0
 public static double PingPong(double t, double length)
 {
     t = Mathd.Repeat(t, length * 2d);
     return(length - Mathd.Abs(t - length));
 }
Example #4
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));
 }