Package org.faceless.graph.math
Class SimpleCurve
- java.lang.Object
-
- org.faceless.graph.math.Curve
-
- org.faceless.graph.math.FunctionCurve
-
- org.faceless.graph.math.SimpleCurve
-
public final class SimpleCurve extends FunctionCurve
A SimpleCurve is a curve that's just a wrapper around java functions likeMath.sin
orMath.tan
-
-
Constructor Summary
Constructors Constructor Description SimpleCurve(java.lang.String name)
The constructor takes the name of the java method that represents the function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
get(double x)
Return the value of the function at the specified X position.java.lang.String
toString()
-
Methods inherited from class org.faceless.graph.math.FunctionCurve
getMax, getMin, point, steps
-
-
-
-
Constructor Detail
-
SimpleCurve
public SimpleCurve(java.lang.String name) throws java.lang.NoSuchMethodException
The constructor takes the name of the java method that represents the function. An example would be
new SimpleCurve("java.lang.Math.sin")
The argument must be the name of a static method that takes a single double parameter and returns a double. If it doesn't meet this criteria an exception is thrown.
- Parameters:
name
- The fully qualified name of the function- Throws:
java.lang.NoSuchMethodException
- if the function doesn't exist, isn't static, doesn't take a double or doesn't return a double.
-
-
Method Detail
-
get
public double get(double x)
Return the value of the function at the specified X position. The function may return NaN or an infinite value, but be warned - if it throws an exception, anError
is thrown by this method.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-