Class PathApproximator

Helper methods to approximate a path by interpolating a sequence of control points.

Constructors

Properties

BEZIER_TOLERANCE: number = ...
CATMULL_DETAIL: 50 = 50

The amount of pieces to calculate for each control point quadruplet.

CIRCULAR_ARC_TOLERANCE: number = ...

Methods

  • Creates a piecewise-linear approximation of a clamped uniform B-spline with polynomial order p, by dividing it into a series of bezier control points at its knots, then adaptively repeatedly subdividing those until their approximation error vanishes below a given threshold. Retains previous bezier approximation functionality when p is 0 or too large to create knots. Algorithm unsuitable for large values of p with many knots.

    Parameters

    • controlPoints: Vector2[]

      The control points.

    • p: number = 0

      The polynomial order.

    Returns Vector2[]

    A list of vectors representing the piecewise-linear approximation.

  • Creates a piecewise-linear approximation of a bezier curve, by adaptively repeatedly subdividing the control points until their approximation error vanishes below a given threshold.

    Parameters

    • controlPoints: Vector2[]

      The control points of the path.

    Returns Vector2[]

    A list of vectors representing the piecewise-linear approximation.

  • Creates a piecewise-linear approximation of a Catmull-Rom spline.

    Parameters

    • controlPoints: Vector2[]

      The control points of the path.

    Returns Vector2[]

    A list of vectors representing the piecewise-linear approximation.

  • Creates a piecewise-linear approximation of a circular arc curve.

    Parameters

    • controlPoints: Vector2[]

      The control points of the path.

    Returns Vector2[]

    A list of vectors representing the piecewise-linear approximation.

  • Creates a piecewise-linear approximation of a lagrange polynomial.

    Parameters

    • controlPoints: Vector2[]

      The control points of the path.

    Returns Vector2[]

    A list of vectors representing the piecewise-linear approximation.

  • Creates a piecewise-linear approximation of a linear curve. Basically, returns the input.

    Parameters

    • controlPoints: Vector2[]

      The control points of the path.

    Returns Vector2[]

    A list of vectors representing the piecewise-linear approximation.