Normand Briere
2016-02-27 28ab4dad99d24372ea58b09a00eafbce1291c278
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package aurelienribon.tweenengine.paths;
 
import aurelienribon.tweenengine.TweenPath;
 
/**
 * @author Aurelien Ribon | http://www.aurelienribon.com/
 */
public class Linear implements TweenPath {
   @Override
   public float compute(float t, float[] points, int pointsCnt) {
       int segment = (int) Math.floor((pointsCnt-1) * t);
       segment = Math.max(segment, 0);
       segment = Math.min(segment, pointsCnt-2);
 
       t = t * (pointsCnt-1) - segment;
 
       return points[segment] + t * (points[segment+1] - points[segment]);
   }
}