com.graphbuilder.math.func.SignFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of curvesapi Show documentation
Show all versions of curvesapi Show documentation
Implementation of various mathematical curves that define themselves over a set of control points. The API is written in Java. The curves supported are: Bezier, B-Spline, Cardinal Spline, Catmull-Rom Spline, Lagrange, Natural Cubic Spline, and NURBS.
package com.graphbuilder.math.func;
/**
The sign function.
*/
public class SignFunction implements Function {
public SignFunction() {}
/**
The sign function returns 1 if the d[0] > 0, -1 if d[0] < 0, else 0.
*/
public double of(double[] d, int numParam) {
if (d[0] > 0) return 1;
if (d[0] < 0) return -1;
return 0;
}
/**
Returns true only for 1 parameter, false otherwise.
*/
public boolean acceptNumParam(int numParam) {
return numParam == 1;
}
public String toString() {
return "sign(x)";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy