code: private double CosineInterpolate(double x1, double x2, double a) {
          double f = (1 - Math.cos(a * Math.PI)) * 0.5;
  
          return x1 * (1 - f) + x2 * f;
      }
docs: Cosine interpolation.
  
  @param x1 X1 Value.
  @param x2 X2 Value.
  @param a  Value.
  @return Value.