public static double PingPong(double t, double length)
 {
     t = MathD.Repeat(t, length * 2d);
     return(length - MathD.Abs(t - length));
 }