comparison game/Interpolate.java @ 1:44f1e7b47fcf

Preliminary work ... puuh.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 28 Jan 2011 16:34:53 +0200
parents
children 70714c229e23
comparison
equal deleted inserted replaced
0:f930f72ed0f5 1:44f1e7b47fcf
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 double start, end, steps;
12
13 public Interpolate(double start, double end, double steps)
14 {
15 this.start = start;
16 this.end = end;
17 this.steps = steps;
18 }
19
20 public double getValue(double step)
21 {
22 double n = step / steps;
23 double v = n * n * (3.0f - 2.0f * n);
24 return (start * v) + (end * (1.0f - v));
25 }
26 }