File-By-File
Spline

Spline

This interface defines a contract for mathematical splines. A spline is a curve that passes through a set of control points, allowing for smooth interpolation between them. Splines are generally most useful for high-performance trajectories, as they can reduce the distance traversed compared to linear paths.

Splines must be created with points that have either strictly increasing or strictly decreasing X values. This ensures monotonicity, which is crucial for the interpolation to work correctly.

Key Concepts

  • Control Points: A set of PointXY objects that define the shape of the spline.
  • Monotonicity: The X-values of the control points must be strictly increasing or strictly decreasing. This means the curve does not double back on itself horizontally.
  • Interpolation: The ability to calculate a Y-value (or a PointXY) for any given X-value along the spline.

Static Methods

areIncreasing(double... values)

Checks if a set of double values are in strictly increasing order.

areDecreasing(double... values)

Checks if a set of double values are in strictly decreasing order.

areMonotonic(double... values)

Checks if a set of double values are monotonic (either strictly increasing or strictly decreasing).

areMonotonicX(PointXY... points)

Checks if the X-values of a set of PointXY objects are monotonic.

areMonotonicY(PointXY... points)

Checks if the Y-values of a set of PointXY objects are monotonic.

areMonotonic(PointXY... points)

Checks if both the X and Y values of a set of PointXY objects are monotonic.

areRelativelyMonotonic(List<PointXY> points)

Checks if a list of PointXY objects are "relatively monotonic." This means that for every group of three adjacent points, those three points must be monotonic. This is a stricter condition than overall monotonicity.

Instance Methods

interpolateY(double x)

Interpolates and returns the Y-value of the spline for a given X-value.

interpolate(double x)

Interpolates and returns a PointXY object on the spline for a given X-value. The Y-value is determined by interpolateY(double x).

getStartPoint()

Returns the starting PointXY of the spline.

getEndPoint()

Returns the ending PointXY of the spline.

getY(double x)

Returns the Y-value of the spline at a specific X-value. This is an alias for interpolateY(double x).