Class RMCurveFit

java.lang.Object
com.inductiveautomation.rm.graphics.RMCurveFit

public class RMCurveFit extends 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.

  • Constructor Details

    • RMCurveFit

      public RMCurveFit()
  • Method Details

    • cheby

      public static double[] cheby(int n)
    • nevilleFit

      public 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. 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(String[] args)