annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Class for smooth non-linear interpolation between two given values in N steps
151
d6d92845d6a2 ISO-8859-1 -> UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
3 * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 */
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 package game;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 import java.util.*;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 public class Interpolate
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 {
106
41c6cca69d60 Make new pieces appear gradually, and same effect for swapping.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
11 public float start, end, steps;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
13 public Interpolate(float start, float end, float steps)
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 {
15
59ff451750fb Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
15 this.start = start;
59ff451750fb Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
16 this.end = end;
59ff451750fb Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
17 this.steps = steps;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 }
134
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 106
diff changeset
19
7
70714c229e23 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
20 public float getValue(float step)
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 {
15
59ff451750fb Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
22 float n = step / steps;
59ff451750fb Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
23 float v = n * n * (3.0f - 2.0f * n);
59ff451750fb Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
24 return (start * v) + (end * (1.0f - v));
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 }