Mercurial > hg > ristipolku
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Interpolate.java Tue Jun 21 12:53:53 2016 +0300 @@ -0,0 +1,26 @@ +/* + * Class for smooth non-linear interpolation between two given values in N steps + * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org> + */ +package game; + +import java.util.*; + +public class Interpolate +{ + public float start, end, steps; + + public Interpolate(float start, float end, float steps) + { + this.start = start; + this.end = end; + this.steps = steps; + } + + public float getValue(float step) + { + float n = step / steps; + float v = n * n * (3.0f - 2.0f * n); + return (start * v) + (end * (1.0f - v)); + } +}