Class RMCurveFit
- java.lang.Object
-
- com.inductiveautomation.rm.graphics.RMCurveFit
-
public class RMCurveFit extends java.lang.Object
This class creates an approximating polygon for a given RMFunction. The polygon is expressed as a series of sample points that can be interpolated between using Neville's method to quickly obtain the value of any function.This is used for path animation, to map the complex curve which maps the arclength of the bezier path segment to the bezier parameter value.
The real function is the solution to an expression which would be prohibitively expensive to try to evaluate inside an animation loop, so instead we create a polynomial approximation and use that instead.
This code is distinct from RMPathFitCurves, which fits a set of bezier curves to a set of sample points.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RMCurveFit.InverseFunc
A function whose value is the inverse of another function ie.static class
RMCurveFit.NevilleFunc
A function whose value is determined by interpolating through a set of sample points using Neville's Method.static class
RMCurveFit.Piece
static class
RMCurveFit.ScaledFunc
A function scaled such that f(1) == 1
-
Constructor Summary
Constructors Constructor Description RMCurveFit()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double[]
cheby(int n)
static void
main(java.lang.String[] args)
static java.util.List
nevilleFit(RMMath.RMFunc func, double start, double end, java.util.List pieceList)
NevilleFit - This routine tries to fit an interpolating polygon to an arbitrary function.
-
-
-
Method Detail
-
cheby
public static double[] cheby(int n)
-
nevilleFit
public static java.util.List nevilleFit(RMMath.RMFunc func, double start, double end, java.util.List pieceList)
NevilleFit - This routine tries to fit an interpolating polygon to an arbitrary function. Neville's method takes a set of points and calculates new points by interpolating between the neighboring samples, and then interpolating between the interpolations, etc, etc. This method tries to create a set of points such that, when plugged into Neville's method, will approximate the curve with minimal error.It first tries to create a linear->5th degree polynomial (corresponding to two to six sample points), and then calculates the maximum error of that polynomial to the real curve. If the error is too great, it subdivides at the maximum error point and recurses.
The final result is a piecewise list of polynomials, expressed as sample points.
-
main
public static void main(java.lang.String[] args)
-
-