Mercurial > hg > ristipolku
view game/Interpolate.java @ 109:84935674c1c9
Added tag dev-0_70 for changeset ae66d21d4747
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 03 Mar 2011 22:30:05 +0200 |
parents | 41c6cca69d60 |
children | 4c0dec72e2f0 |
line wrap: on
line source
/* * 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)); } }