MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ smoothed_velocity() [1/2]

template<typename T >
T MayaFlux::Kinesis::smoothed_velocity ( const Memory::HistoryBuffer< T > &  history,
double  dt,
size_t  window 
)
inlinenoexcept

Velocity averaged over a short window rather than a single interval.

Template Parameters
TSample type
Parameters
historyBuffer with capacity >= window + 1
dtElapsed time between consecutive samples
windowNumber of intervals to average over, minimum 1
Returns
Mean of the per-interval first differences across the window

A single backward_difference<1> reading is sensitive to jitter on any one sample pair. Averaging several consecutive one-step differences trades responsiveness for stability, useful when the source stream (tablet, camera-derived tracking) carries sensor noise that would otherwise alias into a spurious high-frequency acceleration or jerk reading downstream.

Definition at line 213 of file Differential.hpp.

214{
215 using S = scalar_t<T>;
216 window = window < 1 ? 1 : window;
217 const auto s_dt = static_cast<S>(dt);
218 T acc = (history[0] - history[1]) / s_dt;
219 for (size_t i = 1; i < window; ++i)
220 acc = acc + (history[i] - history[i + 1]) / s_dt;
221 return acc / static_cast<S>(window);
222}

Referenced by smoothed_velocity().

+ Here is the caller graph for this function: