package sillysagiri;

public class Easing {

	public static float CubicEaseOut(float p)
	{
		float f = (p - 1);
		return f * f * f + 1;
	}

	public static float CubicEaseIn(float p)
	{
		return p * p * p;
	}
  
  public static float CubicEaseInOut(float p)
  {
    if(p < 0.5)
		{
			return 4 * p * p * p;
		}
		else
		{
			float f = ((2 * p) - 2);
			return 0.5f * f * f * f + 1;
		}
  }

	public static float CircularEaseIn(float p)
	{
		return (float)(1 - Math.sqrt(1 - (p * p)));
	}

	// Modeled after shifted quadrant II of unit circle
	public static float CircularEaseOut(float p)
	{
		return (float)(Math.sqrt((2 - p) * p));
	}

	// Modeled after the piecewise circular function
	// y = (1/2)(1 - sqrt(1 - 4x^2))           ; [0, 0.5)
	// y = (1/2)(sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1]
	public static float CircularEaseInOut(float p)
	{
		if(p < 0.5)
		{
			return (float)(0.5f * (1 - Math.sqrt(1 - 4 * (p * p))));
		}
		else
		{
			return (float)(0.5f * (Math.sqrt(-((2 * p) - 3) * ((2 * p) - 1)) + 1));
		}
	}

	// Modeled after the quintic y = x^5
	public static float QuinticEaseIn(float p) 
	{
		return p * p * p * p * p;
	}

	// Modeled after the quintic y = (x - 1)^5 + 1
	public static float QuinticEaseOut(float p) 
	{
		float f = (p - 1);
		return f * f * f * f * f + 1;
	}

	// Modeled after the piecewise quintic
	// y = (1/2)((2x)^5)       ; [0, 0.5)
	// y = (1/2)((2x-2)^5 + 2) ; [0.5, 1]
	public static float QuinticEaseInOut(float p) 
	{
		if(p < 0.5)
		{
			return 16 * p * p * p * p * p;
		}
		else
		{
			float f = ((2 * p) - 2);
			return  0.5f * f * f * f * f * f + 1;
		}
	}

}
