• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package aurelienribon.tweenengine.equations;
2 
3 import aurelienribon.tweenengine.TweenEquation;
4 
5 /**
6  * Easing equation based on Robert Penner's work:
7  * http://robertpenner.com/easing/
8  * @author Aurelien Ribon | http://www.aurelienribon.com/
9  */
10 public abstract class Sine extends TweenEquation {
11 	private static final float PI = 3.14159265f;
12 
13 	public static final Sine IN = new Sine() {
14 		@Override
15 		public final float compute(float t) {
16 			return (float) -Math.cos(t * (PI/2)) + 1;
17 		}
18 
19 		@Override
20 		public String toString() {
21 			return "Sine.IN";
22 		}
23 	};
24 
25 	public static final Sine OUT = new Sine() {
26 		@Override
27 		public final float compute(float t) {
28 			return (float) Math.sin(t * (PI/2));
29 		}
30 
31 		@Override
32 		public String toString() {
33 			return "Sine.OUT";
34 		}
35 	};
36 
37 	public static final Sine INOUT = new Sine() {
38 		@Override
39 		public final float compute(float t) {
40 			return -0.5f * ((float) Math.cos(PI*t) - 1);
41 		}
42 
43 		@Override
44 		public String toString() {
45 			return "Sine.INOUT";
46 		}
47 	};
48 }