com.metsci.glimpse.util.math
Class LinearInterpolator

java.lang.Object
  extended by com.metsci.glimpse.util.math.LinearInterpolator

public class LinearInterpolator
extends java.lang.Object

Used for piecewise linear interpolation between given 2D points.

Author:
UNKNOWN

Constructor Summary
LinearInterpolator(java.awt.geom.Point2D[] points)
           
 
Method Summary
static LinearInterpolator createFromArrays(double[] x, double[] y)
          Arrays should be arranged so that x[k] corresponds to y[k] for all k.
 double evaluate(double x)
          Returns the interpolated y value for the given x value.
static LinearInterpolator parseLinearInterpolator(java.lang.String function)
          Creates a LinearInterpolator from a String describing the points.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearInterpolator

public LinearInterpolator(java.awt.geom.Point2D[] points)
Parameters:
points - the points used in the interpolation. They do NOT have to be in increasing values of x but must have distinct x values.
Method Detail

evaluate

public double evaluate(double x)
Returns the interpolated y value for the given x value.


createFromArrays

public static LinearInterpolator createFromArrays(double[] x,
                                                  double[] y)
                                           throws java.lang.IllegalArgumentException
Arrays should be arranged so that x[k] corresponds to y[k] for all k.

Throws:
java.lang.IllegalArgumentException

parseLinearInterpolator

public static LinearInterpolator parseLinearInterpolator(java.lang.String function)
                                                  throws java.lang.IllegalArgumentException
Creates a LinearInterpolator from a String describing the points.

Parameters:
function - a string in the format of "x1,y1;x2,y2;x3,y3;...".
Throws:
java.lang.IllegalArgumentException


Copyright © 2012 Metron, Inc.. All Rights Reserved.