summaryrefslogtreecommitdiffstats
path: root/src/demos/xtrans/InterpolatedQuad2f.java
blob: b7262d7d8a2f3d5ec8a3e8650e2224282e416ee3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package demos.xtrans;

import gleem.linalg.*;

/** A quadrilateral of two-dimensional floating-point values which
    interpolates between specified start and end values. */

public class InterpolatedQuad2f {
  private Quad2f start;
  private Quad2f end;

  /** Constructs a new InterpolatedQuad2f. By default both the start
      and end quadrilaterals have all of their points set to the
      origin. */
  public InterpolatedQuad2f() {
    start = new Quad2f();
    end = new Quad2f();
  }

  /** Returns the starting value for the interpolation. */
  public Quad2f getStart() {
    return start;
  }

  /** Sets the starting value for the interpolation. */
  public void setStart(Quad2f quad) {
    start.set(quad);
  }

  /** Returns the ending value for the interpolation. */
  public Quad2f getEnd() {
    return end;
  }

  /** Sets the ending value for the interpolation. */
  public void setEnd(Quad2f quad) {
    end.set(quad);
  }

  /** Gets the current interpolated value at the specified fraction of
      interpolation (0.0 - 1.0). */
  public Quad2f getCurrent(float fraction) {
    return start.times(1.0f - fraction).plus(end.times(fraction));
  }
}