|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.onebusaway.utility.InterpolationLibrary
public class InterpolationLibrary
Generic methods to support interpolation of values against a sorted key-value map given a new target key.
Constructor Summary | |
---|---|
InterpolationLibrary()
|
Method Summary | ||
---|---|---|
static double |
interpolate(double[] keys,
double[] values,
double target,
EOutOfRangeStrategy outOfRangeStrategy)
|
|
static
|
interpolate(InterpolationStrategy<KEY,VALUE> interpolationStrategy,
EOutOfRangeStrategy outOfRangeStrategy,
SortedMap<ANY_KEY,ANY_VALUE> values,
ANY_KEY target)
Given a SortedMap with key-values that of arbitrary type and a
InterpolationStrategy to define interpolation over those types,
interpolate a value for a target key within the key-range of the map. |
|
static
|
interpolate(SortedMap<K,V> values,
K target)
Same behavior as interpolate(SortedMap, Number, EOutOfRangeStrategy) but with a
default EOutOfRangeStrategy of
EOutOfRangeStrategy.INTERPOLATE . |
|
static
|
interpolate(SortedMap<K,V> values,
K target,
EOutOfRangeStrategy outOfRangeStrategy)
Given a SortedMap with key-values that all extend from
Number , interpolate using linear interpolation a value for a target
key within the key-range of the map. |
|
static double |
interpolatePair(double fromValue,
double toValue,
double ratio)
Simple numeric interpolation between two double values using the equation ratio * (toValue - fromValue) + fromValue |
|
static double |
interpolatePair(double keyA,
double valueA,
double keyB,
double valueB,
double targetKey)
Simple numeric interpolation between two pairs of key-values and a third key. |
|
static
|
nearestNeighbor(SortedMap<K,V> values,
K target)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public InterpolationLibrary()
Method Detail |
---|
public static <K extends Number,V extends Number> double interpolate(SortedMap<K,V> values, K target)
interpolate(SortedMap, Number, EOutOfRangeStrategy)
but with a
default EOutOfRangeStrategy
of
EOutOfRangeStrategy.INTERPOLATE
.
values
- a sorted-map of key-value number pairstarget
- the target key used to interpolate a valueoutOfRangeStrategy
- the strategy to use for a target key that outside
the key-range of the value map
public static <K extends Number,V extends Number> double interpolate(SortedMap<K,V> values, K target, EOutOfRangeStrategy outOfRangeStrategy)
SortedMap
with key-values that all extend from
Number
, interpolate using linear interpolation a value for a target
key within the key-range of the map. For a key outside the range of the
keys of the map, the outOfRange
EOutOfRangeStrategy
strategy will determine the interpolation behavior.
values
- a sorted-map of key-value number pairstarget
- the target key used to interpolate a valueoutOfRangeStrategy
- the strategy to use for a target key that outside
the key-range of the value map
public static <K extends Number,V> V nearestNeighbor(SortedMap<K,V> values, K target)
public static double interpolate(double[] keys, double[] values, double target, EOutOfRangeStrategy outOfRangeStrategy)
public static double interpolatePair(double fromValue, double toValue, double ratio)
ratio * (toValue - fromValue) + fromValue
fromValue
- toValue
- ratio
-
ratio * (toValue - fromValue) + fromValue
public static double interpolatePair(double keyA, double valueA, double keyB, double valueB, double targetKey)
ratio = (targetKey - keyA) / (keyB - keyA)
and the
result is ratio * (valueB - valueA) + valueA
.
fromValue
- toValue
- ratio
-
ratio * (toValue - fromValue) + fromValue
public static <KEY extends Number,VALUE,ANY_KEY extends KEY,ANY_VALUE extends VALUE> VALUE interpolate(InterpolationStrategy<KEY,VALUE> interpolationStrategy, EOutOfRangeStrategy outOfRangeStrategy, SortedMap<ANY_KEY,ANY_VALUE> values, ANY_KEY target)
SortedMap
with key-values that of arbitrary type and a
InterpolationStrategy
to define interpolation over those types,
interpolate a value for a target key within the key-range of the map. For a
key outside the range of the keys of the map, the outOfRange
EOutOfRangeStrategy
strategy will determine the interpolation
behavior.
interpolationStrategy
- the interpolation strategy used to perform
interpolation between key-value pairs of arbitrary typeoutOfRangeStrategy
- the strategy to use for a target key that outside
the key-range of the value mapvalues
- a sorted-map of key-value pairstarget
- the target key used to interpolate a value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |