Class NumericalCurveMapper

This curve mapper implementation uses a numerical integration method (Gauss Legendre) in order to approximate curve segment lengths. For re-parameterization of the curve function in terms of arc length, a number of precalculated lengths (samples) is used to fit a monotone piecewise cubic function using the approach suggested here: https://stackoverflow.com/questions/35275073/uniform-discretization-of-bezier-curve

Hierarchy

Constructors

  • Parameters

    • nQuadraturePoints: number = 24

      the number of Gauss-Legendre Quadrature points to use for arc length approximation

    • nInverseSamples: number = 21

      the number of arc length samples to use to fit an inverse function for calculating t from arc length

    • Optional onInvalidateCache: (() => void)

      callback function to be invoked when cache is invalidated

        • (): void
        • Returns void

    Returns NumericalCurveMapper

Properties

_alpha: number = 0.0
_cache: object
_closed: boolean = false
_gauss: number[][]
_nSamples: number = 21
_onInvalidateCache: (() => void) = null

Type declaration

    • (): void
    • Returns void

_points: Vector[]
_subDivisions: number
_tension: number = 0.5

Accessors

Methods

  • Computes the arc length of a curve segment

    Returns

    arc length between t0 and t1

    Parameters

    • index: number

      index of curve segment

    • t0: number = 0.0

      calculate length from t

    • t1: number = 1.0

      calculate length to t

    Returns number

  • Calculate a running sum of arc length for mapping a position on the curve (u) to the position at the corresponding curve segment (t).

    Returns

    array with accumulated curve segment arc lengths

    Returns number[]

  • Get the curve function coefficients at the given segment index. The coefficients are calculated once per segment and put in cache until it is invalidated.

    Returns

    coefficients for the curve function at the given segment index

    Parameters

    • idx: number

      segment index

    Returns any

  • Get samples for inverse function from cache if present, otherwise calculate and put in cache for re-use.

    Returns

    Lengths, slopes and coefficients for inverse function

    Parameters

    • idx: number

      curve segment index

    Returns [number[], number[], number[], number[]]

  • Calculate t from arc length for a curve segment

    Returns

    time (t) along curve segment matching the input length

    Parameters

    • idx: number

      segment index

    • len: number

      length

    Returns number

Generated using TypeDoc