Advertisement
Guest User

Interpolators

a guest
Sep 26th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. public static class Interpolators
  2. {
  3.     public static double Linear(double In)
  4.     {
  5.         return In;
  6.     }
  7.  
  8.     public static double LinearOut(double In)
  9.     {
  10.         return 1.0f - In;
  11.     }
  12.  
  13.     public static double SineIn(double In)
  14.     {
  15.         return Math.Sin(In * (Math.PI / 2));
  16.     }
  17.  
  18.     public static double SineCurve(double In)
  19.     {
  20.         return Math.Sin(In * (Math.PI));
  21.     }
  22.  
  23.     public static double SineOut(double In)
  24.     {
  25.         return 1.0f - SineIn(In);
  26.     }
  27.  
  28.     public static double SmoothStart2(double In)
  29.     {
  30.         return In * In;
  31.     }
  32.  
  33.     public static double SmoothStop2(double In)
  34.     {
  35.         var Flip = (1f - In);
  36.         return (Flip * Flip);
  37.     }
  38.  
  39.     public static double SmoothStart3(double In)
  40.     {
  41.         return In * In * In;
  42.     }
  43.  
  44.     public static double SmoothStop3(double In)
  45.     {
  46.         var Flip = (1f - In);
  47.         return (Flip * Flip * Flip);
  48.     }
  49.  
  50.     public static double Snap(double In)
  51.     {
  52.         return 1.0f;
  53.     }
  54.  
  55.     public static Func<double, double> FlatSineCurve(double b = 4) => In =>
  56.     Math.Sqrt(
  57.         (1 + (b * b)) /
  58.         (1 + (b * b) * (Math.Sin(In * Math.PI) * Math.Sin(In * Math.PI)))
  59.     ) * Math.Sin(In * Math.PI);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement