toxi.math
Class BezierInterpolation

java.lang.Object
  extended by toxi.math.BezierInterpolation
All Implemented Interfaces:
InterpolateStrategy

public class BezierInterpolation
extends java.lang.Object
implements InterpolateStrategy

Bezier curve interpolation with configurable coefficients. The curve parameters need to be normalized offsets relative to the start and end values passed to the interpolate(float, float, float) method, but can exceed the normal 0 .. 1.0 interval. Use symmetrical offsets to create a symmetrical curve, e.g. this will create a curve with 2 dips reaching the minimum and maximum values at 25% and 75% of the interval...

BezierInterpolation b=new BezierInterpolation(3,-3);

The curve will be a straight line with this configuration:

BezierInterpolation b=new BezierInterpolation(1f/3,-1f/3);


Field Summary
 float c1
           
 float c2
           
 
Constructor Summary
BezierInterpolation(float h1, float h2)
           
 
Method Summary
 float interpolate(float a, float b, float t)
          Implements an interpolation equation.
 void setCoefficients(float a, float b)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

c1

public float c1

c2

public float c2
Constructor Detail

BezierInterpolation

public BezierInterpolation(float h1,
                           float h2)
Method Detail

interpolate

public float interpolate(float a,
                         float b,
                         float t)
Description copied from interface: InterpolateStrategy
Implements an interpolation equation.

Specified by:
interpolate in interface InterpolateStrategy
Parameters:
a - current value
b - target value
t - normalized interpolation factor (0.0 .. 1.0)
Returns:
interpolated value

setCoefficients

public void setCoefficients(float a,
                            float b)