1
|
1 /*
|
|
2 * Class for smooth non-linear interpolation between two given values in N steps
|
|
3 * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
|
|
4 */
|
|
5 package game;
|
|
6
|
|
7 import java.util.*;
|
|
8
|
|
9 public class Interpolate
|
|
10 {
|
7
|
11 float start, end, steps;
|
1
|
12
|
7
|
13 public Interpolate(float start, float end, float steps)
|
1
|
14 {
|
|
15 this.start = start;
|
|
16 this.end = end;
|
|
17 this.steps = steps;
|
|
18 }
|
|
19
|
7
|
20 public float getValue(float step)
|
1
|
21 {
|
7
|
22 float n = step / steps;
|
|
23 float v = n * n * (3.0f - 2.0f * n);
|
1
|
24 return (start * v) + (end * (1.0f - v));
|
|
25 }
|
|
26 }
|