public class RMCurveFit
extends java.lang.Object
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.
Modifier and Type | Class and 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 and Description |
---|
RMCurveFit() |
Modifier and Type | Method and 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.
|
public static double[] cheby(int n)
public static java.util.List nevilleFit(RMMath.RMFunc func, double start, double end, java.util.List pieceList)
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.
public static void main(java.lang.String[] args)