#pragma once
#include <cmath>

namespace ease {

  enum Style {
    NONE=0,
    SINE=1,
    OUT_CIRC=2,
    OUT_BOUNCE=3,
    IN_OUT_BACK=4,
    FUCKFACE
  };

  inline double sine(double x) {
    return (std::sin(x) + 1.0) / 2.0;
  }

  inline double out_circ(double x) {
    return std::sqrt(1.0f - ((x - 1.0f) * (x - 1.0f)));
  }

  inline double out_bounce(double x) {
    constexpr const double n1 = 7.5625;
    constexpr const double d1 = 2.75;

    if (x < 1 / d1) {
      return n1 * x * x;
    } else if (x < 2 / d1) {
      x -= 1.5;
      return n1 * (x / d1) * x + 0.75;
    } else if (x < 2.5 / d1) {
      x -= 2.25;
      return n1 * (x / d1) * x + 0.9375;
    } else {
      x -= 2.625;
      return n1 * (x / d1) * x + 0.984375;
    }
  }

  inline double in_out_back(double x) {
    constexpr const double c1 = 1.70158;
    constexpr const double c2 = c1 * 1.525;

    return x < 0.5
      ? (std::pow(2.0 * x, 2.0) * ((c2 + 1.0) * 2.0 * x - c2)) / 2.0
      : (std::pow(2.0 * x - 2.0, 2.0) * ((c2 + 1.0) * (x * 2.0 - 2.0) + c2) + 2.0) / 2.0;
  }
}
