Class ExponentialInterpolator

java.lang.Object
com.softsynth.jmsl.util.ExponentialInterpolator
All Implemented Interfaces:
Interpolator

public class ExponentialInterpolator
extends java.lang.Object
implements Interpolator
Interpolate a value along an exponentially rising curve defined by two points (x1,y1) and (x2,y2) where x1 < x2, y1 < y2.
The shape of f(x) = exp(x) on the interval [0..steepness] is fitted to the user's endpoints.
That is, (x1,y1) corresponds to (0, 1) and (x2,y2) corresponds to (1,e^steepness), and this new curve resembles a stretched or compressed version of the exp(x) function.

steepness values around 2 or 3 are reasonably gentle. Steepness around 8 and larger gets very steep, meaning most of your output range will be close to zero except for the very top end.
  • Constructor Summary

    Constructors
    Constructor Description
    ExponentialInterpolator​(double x1, double y1, double x2, double y2)
    Construct an interpolator that fits a curve between (x1, y1) and (x2, y2) to an exponentially rising function.
  • Method Summary

    Modifier and Type Method Description
    double interp​(double x)
    Interpolate a value along exponential curve
    static void main​(java.lang.String[] args)
    Use interpolator as a random distribution function
    void setInterp​(double x1, double y1, double x2, double y2)
    Set two endpoints points on the desired curve, to be shaped as f(x)=exp(x) on (0,1)..(1,e)
    precondition: x1
    void setSteepness​(double s)
    Reasonable values are 2..16

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ExponentialInterpolator

      public ExponentialInterpolator​(double x1, double y1, double x2, double y2)
      Construct an interpolator that fits a curve between (x1, y1) and (x2, y2) to an exponentially rising function. Default steepness = 1. Higher values scales y2-y1 range and sharpens the curve's rise
  • Method Details

    • setInterp

      public void setInterp​(double x1, double y1, double x2, double y2)
      Set two endpoints points on the desired curve, to be shaped as f(x)=exp(x) on (0,1)..(1,e)
      precondition: x1
      Specified by:
      setInterp in interface Interpolator
    • interp

      public double interp​(double x)
      Interpolate a value along exponential curve
      Specified by:
      interp in interface Interpolator
    • setSteepness

      public void setSteepness​(double s)
      Reasonable values are 2..16
    • main

      public static void main​(java.lang.String[] args)
      Use interpolator as a random distribution function