Class MultiPointInterpolator


  • public class MultiPointInterpolator
    extends java.lang.Object
    Provides linear interpolation through a map of two variables.

    This is not a full line- or curve- fitting interpolation, it only considers the two closest values in the map.

    • Constructor Summary

      Constructors 
      Constructor Description
      MultiPointInterpolator​(java.util.TreeMap<java.lang.Double,​java.lang.Double> points)
      Constructs a MultiPointInterpolator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void putNewPair​(double key, double value)
      Adds a new key/value pair to to the map at runtime.
      void putNewPairs​(java.util.TreeMap<java.lang.Double,​java.lang.Double> points)
      Adds to the map at runtime.
      double sample​(double key)
      Samples the profile for a value at a given key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiPointInterpolator

        public MultiPointInterpolator​(java.util.TreeMap<java.lang.Double,​java.lang.Double> points)
                               throws java.security.InvalidParameterException
        Constructs a MultiPointInterpolator.
        Parameters:
        points - A map of doubles, with the first term representing the independent variable (time etc.), and the second the value.
        Throws:
        java.security.InvalidParameterException - If the map is empty.
    • Method Detail

      • putNewPairs

        public void putNewPairs​(java.util.TreeMap<java.lang.Double,​java.lang.Double> points)
        Adds to the map at runtime.
        Parameters:
        points - A TreeMap, in the same format as the one used for construction.
      • putNewPair

        public void putNewPair​(double key,
                               double value)
        Adds a new key/value pair to to the map at runtime.
        Parameters:
        key - Double value of the key.
        value - Double value of the... value.
      • sample

        public double sample​(double key)
                      throws java.security.InvalidParameterException
        Samples the profile for a value at a given key.
        Parameters:
        key - A double representing the key to sample.
        Returns:
        The value at that place, linearly interpolated if not already defined by the input map.
        Throws:
        java.security.InvalidParameterException - If the key to sample is less than zero.