comparison game/Interpolate.java @ 162:e8eeac403e5f

Backed out changeset fb33d3796942
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 01 Dec 2016 14:33:25 +0200
parents src/Interpolate.java@fb33d3796942
children
comparison
equal deleted inserted replaced
161:fb33d3796942 162:e8eeac403e5f
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 }