Documentation
    Preparing search index...

    Class CatmullRomTrajectory

    Catmull-Rom spline through every waypoint (§13 "Catmull-Rom spline"), with centripetal knot parameterization by default (alpha = 0.5).

    Centripetal parameterization is the default because it is the variant that provably produces no cusps and no self-intersections within a segment, which is what makes a waypoint path safe to hand to a camera or a robot. alpha = 0 gives the classic uniform spline (which can loop near sharp turns) and alpha = 1 the chordal one.

    Knots are cumulative chord lengths raised to alpha (k[i+1] = k[i] + |p[i+1] − p[i]|^alpha, floored at 1e-8 so coincident waypoints cannot divide by zero). The two end conditions are reflected virtual points — 2·p₀ − p₁ before the start and 2·pₙ₋₁ − pₙ₋₂ after the end — rather than duplicated endpoints, which would produce a zero knot spacing in exactly the formula that divides by it. With two waypoints the reflection makes the spline the straight line between them at constant speed.

    Each segment is the non-uniform cubic Hermite whose tangents are the Catmull-Rom finite differences

    m₁ = (t₂−t₁)·((p₁−p₀)/(t₁−t₀) − (p₂−p₀)/(t₂−t₀) + (p₂−p₁)/(t₂−t₁))
    m₂ = (t₂−t₁)·((p₂−p₁)/(t₂−t₁) − (p₃−p₁)/(t₃−t₁) + (p₃−p₂)/(t₃−t₂))
    

    time maps affinely onto the knot span: s(t) = k₀ + (t / duration)·span. Each segment therefore gets a share of duration proportional to its knot length, so with alpha = 1 the traversal is close to constant speed and with the default alpha = 0.5 it slows through tight turns. Because the mapping is affine, velocity and acceleration are exact: no derivative-of-the-mapping term appears.

    Sampling outside [0, duration] extrapolates the first or last segment's cubic (see the module note).

    Implements

    Index
    alpha: number

    Knot exponent: 0 uniform, 0.5 centripetal, 1 chordal.

    duration: number

    Natural extent of the path in seconds. See the module note on extrapolation.

    points: readonly Vector3[]

    The waypoints, copied.

    • Second derivative of position at time, per second squared. Writes into out when given.

      Parameters

      Returns Vector3

    • Position at time seconds. Writes into out when given.

      Parameters

      Returns Vector3

    • First derivative of position at time, per second. Writes into out when given.

      Parameters

      Returns Vector3