Package com.softsynth.jmsl.util
Class LinearInterpolator
java.lang.Object
com.softsynth.jmsl.util.LinearInterpolator
- All Implemented Interfaces:
Interpolator
public class LinearInterpolator extends java.lang.Object implements Interpolator
Interpolate a value along a line defined by two points (x1,y1) and (x2,y2)
- Author:
- Phil Burk and Nick Didkovsky
-
Constructor Summary
Constructors Constructor Description LinearInterpolator(double x1, double y1, double slope)
LinearInterpolator(double ex1, double why1, double ex2, double why2)
Construct a linear interpolator that intersects two specified points -
Method Summary
Modifier and Type Method Description double
interp(double x)
Given the input x, return the y along the interpolator's linear functionstatic void
main(java.lang.String[] args)
build an interpolator and print 20 points along the linevoid
setInterp(double ex1, double why1, double ex2, double why2)
Set the interpolator to calculate points along the line intersecting two specified pointsjava.lang.String
toString()
print meMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
LinearInterpolator
public LinearInterpolator(double x1, double y1, double slope) -
LinearInterpolator
public LinearInterpolator(double ex1, double why1, double ex2, double why2)Construct a linear interpolator that intersects two specified points
-
-
Method Details
-
setInterp
public void setInterp(double ex1, double why1, double ex2, double why2)Set the interpolator to calculate points along the line intersecting two specified points- Specified by:
setInterp
in interfaceInterpolator
-
interp
public double interp(double x)Given the input x, return the y along the interpolator's linear function- Specified by:
interp
in interfaceInterpolator
-
toString
public java.lang.String toString()print me- Overrides:
toString
in classjava.lang.Object
-
main
public static void main(java.lang.String[] args)build an interpolator and print 20 points along the line
-