Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## toxi.math
Class ScaleMap

    java.lang.Object
      toxi.math.ScaleMap

    public class ScaleMap

extends java.lang.Object

This class maps values from one interval into another. By default the mapping is using linear projection, but can be changed by using alternative `InterpolateStrategy` implementations to achieve a non-regular mapping.

Constructor Summary
`ScaleMap(double minIn, double maxIn, double minOut, double maxOut)` Creates a new instance to map values between the 2 number ranges specified.

Method Summary
`double` | `getClippedValueFor(double val)` Computes mapped value in the target interval and ensures the input value is clipped to source interval.
`double` | `getInputMedian()`
`DoubleRange` | `getInputRange()`
`double` | `getMappedMedian()`
`double` | `getMappedValueFor(double val)` Computes mapped value in the target interval.
`double` | `getOutputMedian()`
`DoubleRange` | `getOutputRange()`
`void` | `setInputRange(double min, double max)` Sets new minimum & maximum values for the input range
`void` | `setMapFunction(InterpolateStrategy func)` Overrides the mapping function used for the scale conversion.
`void` | `setOutputRange(double min, double max)` Sets new minimum & maximum values for the output/target range

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ScaleMap

    public ScaleMap(double minIn,
                    double maxIn,
                    double minOut,
                    double maxOut)

  Creates a new instance to map values between the 2 number ranges specified. By default linear projection is used.

  Parameters:
    `minIn` -
    `maxIn` -
    `minOut` -
    `maxOut` -

Method Detail

### getClippedValueFor

    public double getClippedValueFor(double val)

  Computes mapped value in the target interval and ensures the input value is clipped to source interval.

  Parameters:
    `val` -
  Returns:
    mapped value

### getInputMedian

    public double getInputMedian()

  Returns:
    the middle value of the input range.

### getInputRange

    public DoubleRange getInputRange()

  Returns:
    the in

### getMappedMedian

    public double getMappedMedian()

  Returns:
    the mapped middle value of the output range. Depending on the mapping function used, this value might be different to the one returned by `getOutputMedian()`.

### getMappedValueFor

    public double getMappedValueFor(double val)

  Computes mapped value in the target interval. Does check if input value is outside the input range.

  Parameters:
    `val` -
  Returns:
    mapped value

### getOutputMedian

    public double getOutputMedian()

  Returns:
    the middle value of the output range

### getOutputRange

    public DoubleRange getOutputRange()

  Returns:
    the output range

### setInputRange

    public void setInputRange(double min,
                              double max)

  Sets new minimum & maximum values for the input range

  Parameters:
    `min` -
    `max` -

### setMapFunction

    public void setMapFunction(InterpolateStrategy func)

  Overrides the mapping function used for the scale conversion.

  Parameters:
    `func` - interpolate strategy implementation

### setOutputRange

    public void setOutputRange(double min,
                               double max)

  Sets new minimum & maximum values for the output/target range

  Parameters:
    `min` - new min output value
    `max` - new max output value

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD