package speiger.src.coreengine.math.easing;

import speiger.src.coreengine.math.MathUtils;

public class EasingFunctions {
	public static double easeInSine(double progress) {
		return 1D - MathUtils.cos(progress * MathUtils.HALF_PI);
	}
	
	public static double easeOutSine(double progress) {
		return MathUtils.sin(progress * MathUtils.HALF_PI);
	}
	
	public static double easeInOutSine(double progress) {
		return -MathUtils.cos(progress * Math.PI - 1D) * 0.5D;
	}
	
	public static double easeInSqrt(double progress) {
		return Math.sqrt(progress);
	}
	
	public static double easeOutSqrt(double progress) {
		return 1D - Math.sqrt(1D - progress);
	}
	
	public static double easeInOutSqrt(double progress) {
		return progress < 0.5D ? Math.sqrt(progress) : 1D-Math.sqrt(1-progress);
	}
	
	public static double easeInQuad(double progress) {
		return progress * progress;
	}
	
	public static double easeOutQuad(double progress) {
		double inverse = 1D - progress;
		return 1D - (inverse * inverse);
	}
	
	public static double easeInOutQuad(double progress) {
		if(progress < 0.5D) return 2D * progress * progress;
		double inverse = 1D - progress;
		return 1D - (-4D * (1D - inverse * inverse) + 4D) * 0.5D;
	}
	
	public static double easeInExpo(double progress) {
		return Math.pow(2D, (10D * progress) - 10D);
	}
	
	public static double easeOutExpo(double progress) {
		return 1D - Math.pow(2D, -10D * progress);
	}
	
	public static double easeInOutExpo(double progress) {
		return progress <= 0.5D ? Math.pow(2D, (20D * progress) - 10D) * 0.5D : (2D - Math.pow(2D, (-20D * progress) + 10D)) * 0.5D;
	}
	
	
}
