gov.sns.tools
Class LinearInterpolator

java.lang.Object
  |
  +--gov.sns.tools.LinearInterpolator

public final class LinearInterpolator
extends java.lang.Object

LinearInterpolator calculates the linear interpolated value at at any point within the bounds of an array of values.


Field Summary
protected  double _start
           
protected  double _step
           
protected  double[] _values
           
 
Constructor Summary
LinearInterpolator(double[] values, double start, double step)
          Creates a new instance of Interpolator.
 
Method Summary
 double calcValueAt(double point)
          Calculate the interpolated value at the specified point in the domain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_values

protected final double[] _values

_start

protected final double _start

_step

protected final double _step
Constructor Detail

LinearInterpolator

public LinearInterpolator(double[] values,
                          double start,
                          double step)
Creates a new instance of Interpolator.

Parameters:
values - is the array of values at fixed intervals.
start - is the start of the domain of points and corresponds to the first array element
step - is the step in the domain for each successive element in the array
Method Detail

calcValueAt

public double calcValueAt(double point)
                   throws java.lang.ArrayIndexOutOfBoundsException
Calculate the interpolated value at the specified point in the domain. The point must reside within the domain of points from start to start + step * values.length.

Parameters:
point - The point in the domain for which we should interpolate the value.
Returns:
The interpolated value.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the point does not fall int the accepted domain