← back to roto on ba3a.dev

TrackSmoothing

Gap filling and smoothing of a per-frame track; plain arithmetic in a fixed order, so exact.

Functions

Link copied to clipboard
fun fillGaps(values: List<Double?>): List<Double>

values with every null filled: linearly between the known values either side of a gap, and with the nearest known value before the first or after the last. Throws when none is known.

Link copied to clipboard
fun movingAverage(values: List<Double>, window: Int): List<Double>

The centred moving average of values over window frames. Near either end the window shrinks evenly on both sides, so a figure moving at a steady speed is followed exactly.