comparison src/Interpolate.java @ 161:fb33d3796942

Rename source directory.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 21 Jun 2016 12:53:53 +0300
parents game/Interpolate.java@d6d92845d6a2
children
comparison
equal deleted inserted replaced
160:d5fbad999841 161:fb33d3796942
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 {
11 public float start, end, steps;
12
13 public Interpolate(float start, float end, float steps)
14 {
15 this.start = start;
16 this.end = end;
17 this.steps = steps;
18 }
19
20 public float getValue(float step)
21 {
22 float n = step / steps;
23 float v = n * n * (3.0f - 2.0f * n);
24 return (start * v) + (end * (1.0f - v));
25 }
26 }