示例#1
0
        public static double LerpAngle(double a, double b, double t)
        {
            double num = MathD.Repeat(b - a, 360d);

            if (num > 180.0d)
            {
                num -= 360d;
            }

            return(a + num * MathD.Clamp01(t));
        }
示例#2
0
        public static double DeltaAngle(double current, double target)
        {
            double num = MathD.Repeat(target - current, 360d);

            if (num > 180.0d)
            {
                num -= 360d;
            }

            return(num);
        }
示例#3
0
        public static double SmoothDamp(double current, double target, ref double currentVelocity, double smoothTime, double maxSpeed, double deltaTime)
        {
            smoothTime = MathD.Max(0.0001d, smoothTime);
            double num1 = 2d / smoothTime;
            double num2 = num1 * deltaTime;
            double num3 = (1.0d / (1.0d + num2 + 0.479999989271164d * num2 * num2 + 0.234999999403954d * num2 * num2 * num2));
            double num4 = current - target;
            double num5 = target;
            double max  = maxSpeed * smoothTime;
            double num6 = MathD.Clamp(num4, -max, max);

            target = current - num6;
            double num7 = (currentVelocity + num1 * num6) * deltaTime;

            currentVelocity = (currentVelocity - num1 * num7) * num3;
            double num8 = target + (num6 + num7) * num3;

            if (num5 - current > 0.0 == num8 > num5)
            {
                num8            = num5;
                currentVelocity = (num8 - num5) / deltaTime;
            }
            return(num8);
        }
示例#4
0
 public static double PingPong(double t, double length)
 {
     t = MathD.Repeat(t, length * 2d);
     return(length - Math.Abs(t - length));
 }
示例#5
0
 public static double SmoothDampAngle(double current, double target, ref double currentVelocity, double smoothTime, double maxSpeed, double deltaTime)
 {
     return(MathD.SmoothDamp(current, current + MathD.DeltaAngle(current, target), ref currentVelocity, smoothTime, maxSpeed, deltaTime));
 }
示例#6
0
 public static double SmoothDampAngle(double current, double target, ref double currentVelocity, double smoothTime)
 {
     return(MathD.SmoothDampAngle(current, target, ref currentVelocity, smoothTime, double.PositiveInfinity, Time.deltaTime));
 }
示例#7
0
 public static double SmoothDamp(double current, double target, ref double currentVelocity, double smoothTime, double maxSpeed)
 {
     return(MathD.SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, Time.deltaTime));
 }
示例#8
0
 public static bool Approximately(double a, double b)
 {
     return(Math.Abs(b - a) < MathD.Max(1E-06d * MathD.Max(Math.Abs(a), Math.Abs(b)), double.Epsilon));
 }
示例#9
0
 public static double SmoothStep(double from, double to, double t)
 {
     t = MathD.Clamp01(t);
     t = (-2.0 * t * t * t + 3.0 * t * t);
     return(to * t + from * (1.0 - t));
 }
示例#10
0
 public static double MoveTowardsAngle(double current, double target, double maxDelta)
 {
     target = current + MathD.DeltaAngle(current, target);
     return(MathD.MoveTowards(current, target, maxDelta));
 }
示例#11
0
 public static double Lerp(double from, double to, double t)
 {
     return(from + (to - from) * MathD.Clamp01(t));
 }