Class RMCurveFit
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 ClassesModifier and TypeClassDescriptionstatic class
A function whose value is the inverse of another function ie.static class
A function whose value is determined by interpolating through a set of sample points using Neville's Method.static class
static class
A function scaled such that f(1) == 1 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double[]
cheby
(int n) static void
static List
nevilleFit
(RMMath.RMFunc func, double start, double end, List pieceList) NevilleFit - This routine tries to fit an interpolating polygon to an arbitrary function.
-
Constructor Details
-
RMCurveFit
public RMCurveFit()
-
-
Method Details
-
cheby
public static double[] cheby(int n) -
nevilleFit
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
-