|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.math.Interpolation
public class Interpolation
This class provides algorithms to do interpolation. Currently, zero, first, and third order interpolations are supported. These are the interpolation orders most often used in practice. zero order interpolation holds the last reference value; first order does linear interpolation; and third order interpolation is based on the Hermite curves in chapter 11 of "Computer Graphic, Principles and Practice", by Foley, van Dam, Feiner and Hughes, 2nd ed. in C, 1996.
The setValues() method specifies the reference values as a double array. setIndexes() specifies the indexes of those values as an int array. These two arrays must have the same length, and the indexes must be increasing and non-negative; otherwise an exception will be thrown. The values are periodic if a positive period is set by setPeriod(). In this case, the period must be greater than the largest index, and values within the index range 0 to (period-1) are repeated indefinitely. If the period is zero, the values are not periodic, and the values outside the range of the indexes are considered to be 0.0. The interpolation order is set by setOrder().
The default reference values are {1.0, 0.0} and the indexes are {0, 1}. The default period is 2 and the order is 0.
red (cxh) |
Yellow (yuhong) |
Field Summary | |
---|---|
private int[] |
_indexes
|
private int |
_order
|
private int |
_period
|
private double[] |
_values
|
Constructor Summary | |
---|---|
Interpolation()
Construct an instance of Interpolation using the default parameters. |
Method Summary | |
---|---|
private double |
_hermite(int index,
int iStart,
double vStart,
double tanStart,
int iEnd,
double vEnd,
double tanEnd)
|
int[] |
getIndexes()
Return the reference indexes. |
int |
getOrder()
Return the interpolation order. |
int |
getPeriod()
Return the value repetition period. |
double[] |
getValues()
Return the reference values. |
double |
interpolate(int index)
Return the interpolation result for the specified index. |
void |
setIndexes(int[] indexes)
Set the reference indexes. |
void |
setOrder(int order)
Set the interpolation order. |
void |
setPeriod(int period)
Set the value repetition period. |
void |
setValues(double[] values)
Set the reference values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int[] _indexes
private double[] _values
private int _period
private int _order
Constructor Detail |
---|
public Interpolation()
Method Detail |
---|
public int[] getIndexes()
setIndexes(int[])
public int getOrder()
setOrder(int)
public int getPeriod()
setPeriod(int)
public double[] getValues()
setValues(double[])
public double interpolate(int index)
index
- The point of interpolation. Can be negative
java.lang.IllegalStateException
- If the index and value arrays
do not have the same length, or the period is not 0 and not
greater than the largest index.public void setIndexes(int[] indexes)
indexes
- An int array.
java.lang.IllegalArgumentException
- If the argument array is
not increasing and non-negative.getIndexes()
public void setOrder(int order)
order
- An int.
java.lang.IllegalArgumentException
- If the order is not 0, 1, or 3.getOrder()
public void setPeriod(int period)
period
- An int.
java.lang.IllegalArgumentException
- If the period is negative.getPeriod()
public void setValues(double[] values)
values
- A double array.getValues()
private double _hermite(int index, int iStart, double vStart, double tanStart, int iEnd, double vEnd, double tanEnd)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |