hmi.math
Class HermiteSpline

java.lang.Object
  extended by hmi.math.HermiteSpline

public final class HermiteSpline
extends Object

Hermite spline A cubic, acceleration-continu spline going fluently through equidistant (with distant 1) interpolation points. The acceleration in these points is calculated using Catmull-Rom: Px'=0.5*(P(x-1)-P(x+1))

Author:
Herwin van Welbergen

Field Summary
private  float[] interpolationPoints
           
private  float m0
           
private  float mn
           
 
Constructor Summary
HermiteSpline()
          Constructor, m0, mn and interpolation points have to be set manually when this zero-argument constructor is used
HermiteSpline(float[] val)
          Constructor, speed=0 at start and end points
HermiteSpline(float[] val, float startSpeed, float endSpeed)
          Constructor
 
Method Summary
 float eval(float t)
          Get the interpolation value at time t
static float getValue(float t, float p_1, float p0, float p1, float p2)
          Gets the value of the hermite spline at point p0 < t < p1
static float getValueCustomSpeed(float t, float p0, float p1, float m0, float m1)
          Get the interpolation value for custom speed at interpolation points p0 and p1
private static double H0(double t)
           
private static double H1(double t)
           
private static double H2(double t)
           
private static double H3(double t)
           
 void setInterpolationPoints(float[] interpolationPoints)
           
 void setM0(float m0)
           
 void setMn(float mn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

interpolationPoints

private float[] interpolationPoints

m0

private float m0

mn

private float mn
Constructor Detail

HermiteSpline

public HermiteSpline()
Constructor, m0, mn and interpolation points have to be set manually when this zero-argument constructor is used


HermiteSpline

public HermiteSpline(float[] val)
Constructor, speed=0 at start and end points

Parameters:
val - points to interpolate through

HermiteSpline

public HermiteSpline(float[] val,
                     float startSpeed,
                     float endSpeed)
Constructor

Parameters:
val - points to interpolate through
startSpeed - speed at p0
endSpeed - speed at pn
Method Detail

H0

private static double H0(double t)

H1

private static double H1(double t)

H2

private static double H2(double t)

H3

private static double H3(double t)

eval

public float eval(float t)
Get the interpolation value at time t

Parameters:
t - time
Returns:
the interpolation value, interpolationPoints[interpolationPoints.length-1] if t >= interpolationPoints.length-1

getValueCustomSpeed

public static float getValueCustomSpeed(float t,
                                        float p0,
                                        float p1,
                                        float m0,
                                        float m1)
Get the interpolation value for custom speed at interpolation points p0 and p1

Parameters:
t - time 0<=t<=1
p0 - 1st interpolation point
p1 - 2nd interpolation point
m0 - speed at p0
m1 - speed at p1
Returns:
the interpolation value

getValue

public static float getValue(float t,
                             float p_1,
                             float p0,
                             float p1,
                             float p2)
Gets the value of the hermite spline at point p0 < t < p1

Parameters:
t - time
p_1 - point p-1
p0 - point p0
p1 - point p1
p2 - point p2
Returns:
the interpolation value

setInterpolationPoints

public void setInterpolationPoints(float[] interpolationPoints)
Parameters:
interpolationPoints - The interpolationPoints to set.

setM0

public void setM0(float m0)
Parameters:
m0 - The m0 to set.

setMn

public void setMn(float mn)
Parameters:
mn - The mn to set.