MotionTrimming extension

Extension methods for Motion to provide convenient trimming functionality.

Motion wrappers are immutable value objects; construct and reuse them, because parents whose simulations don't report their timing are probed on each Motion.createSimulation.

Important: Trimming behavior varies by motion type:

  • Deterministic motions (like CurvedMotion): Trimming is exact and produces precisely the requested portion of the motion curve.
  • Physics-based motions (like SpringMotion): Trimming is an approximation that extends the simulation range and maps progress back to the desired output. The result approximates the characteristic curve behavior but may not be perfectly accurate to the original motion's physics at every point.
on

Methods

segment({required double length, double start = 0.0}) → TrimmedMotion

Available on Motion, provided by the MotionTrimming extension

Creates a TrimmedMotion that uses a sub-extent of this motion.
sliced({double from = 0.0, double to = 1.0}) → TrimmedMotion

Available on Motion, provided by the MotionTrimming extension

Creates a TrimmedMotion that represents a slice of this motion.
trimmed({double fromStart = 0.0, double fromEnd = 0.0}) → TrimmedMotion

Available on Motion, provided by the MotionTrimming extension

A motion that uses only a portion of another motion's characteristic curve.