Package com.softsynth.jmsl.util
Class ExponentialDecayInterpolator
java.lang.Object
com.softsynth.jmsl.util.ExponentialDecayInterpolator
- All Implemented Interfaces:
Interpolator
public class ExponentialDecayInterpolator extends java.lang.Object implements Interpolator
Interpolate a value along an exponentially decreasing curve defined by two points
(x1,y1) and (x2,y2) where x1 < x2, y1 > y2.
The shape of f(x) = 1/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 1/exp(x) function.
The shape of f(x) = 1/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 1/exp(x) function.
-
Constructor Summary
Constructors Constructor Description ExponentialDecayInterpolator(double x1, double y1, double x2, double y2)
Construct an interpolator that fits a curve between (x1, y1) and (x2, y2) to an exponentially decaying function. -
Method Summary
Modifier and Type Method Description double
interp(double x)
Interpolate a value along exponential curvevoid
setInterp(double x1, double y1, double x2, double y2)
Set two endpoints points on the desired curve, to be shaped as f(x)=1/exp(x) on (0,1)..(32,)
so (x1, y1) corresponds to (0,1) which is (0, 1/e^0) and (x2, y2) basically corresponds to at what point do you want x to give a value close to 0.void
setSteepness(double s)
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
ExponentialDecayInterpolator
public ExponentialDecayInterpolator(double x1, double y1, double x2, double y2)Construct an interpolator that fits a curve between (x1, y1) and (x2, y2) to an exponentially decaying function.
-
-
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)=1/exp(x) on (0,1)..(32,)
so (x1, y1) corresponds to (0,1) which is (0, 1/e^0) and (x2, y2) basically corresponds to at what point do you want x to give a value close to 0. For now, y2 itself is ignored. precondition: x1y2 - Specified by:
setInterp
in interfaceInterpolator
-
interp
public double interp(double x)Interpolate a value along exponential curve- Specified by:
interp
in interfaceInterpolator
-
setSteepness
public void setSteepness(double s)
-