com.hdcookbook.grin.features.parts
Class EasingEquation

java.lang.Object
  extended by com.hdcookbook.grin.features.parts.EasingEquation
Direct Known Subclasses:
PointsEasingEquation

public abstract class EasingEquation
extends java.lang.Object

This abstract class represents an easing function that can be used by the GRIN compiler to generate a linear interpolation. See ShowParser to see how to tie this to a particular easing function.


Field Summary
static int framesAdded
          Total number of keyframes added to approximate interpolations.
 
Constructor Summary
EasingEquation()
           
 
Method Summary
 void addKeyFrames(java.util.ArrayList<int[]> keyFrames, int[] end)
          Approximate this easing function with linear interpolation segments, making sure that the error doesn't exceed maxError units.
abstract  double evaluate(double t, double b, double c, double d)
          Evaluate the eqsing equation.
 void setMaxError(int maxError)
          Set the maximum allowed error when generating linear interpolations from this equation.
protected  void trimUnneededKeyFrames(int startFrame, java.util.ArrayList<int[]> keyFrames, int[] end, int[][] allFrames)
          Approximate the list of keyFrames with a reduced list, within the error band of this easing equation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

framesAdded

public static int framesAdded
Total number of keyframes added to approximate interpolations.

Constructor Detail

EasingEquation

public EasingEquation()
Method Detail

evaluate

public abstract double evaluate(double t,
                                double b,
                                double c,
                                double d)
Evaluate the eqsing equation.

Parameters:
t - current time in frames, seconds, or any other unit
b - beginning value
c - change in value
d - duration in frames, seconds, or any other unit

setMaxError

public void setMaxError(int maxError)
Set the maximum allowed error when generating linear interpolations from this equation. Defaults to zero.


addKeyFrames

public void addKeyFrames(java.util.ArrayList<int[]> keyFrames,
                         int[] end)
                  throws java.io.IOException
Approximate this easing function with linear interpolation segments, making sure that the error doesn't exceed maxError units. We start the easing from keyFrames[size-1], and add to keyFrames.

Parameters:
keyFrames - a list of { frame#, value, ... } int arrays
end - Where to ease to, { frame#, value, ... }
Throws:
java.io.IOException

trimUnneededKeyFrames

protected void trimUnneededKeyFrames(int startFrame,
                                     java.util.ArrayList<int[]> keyFrames,
                                     int[] end,
                                     int[][] allFrames)
                              throws java.io.IOException
Approximate the list of keyFrames with a reduced list, within the error band of this easing equation. This is called from addKeyFrames().

Throws:
java.io.IOException