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

◆ damp()

template<typename T >
T MayaFlux::Kinesis::damp ( T  current,
T  target,
T  smoothing,
T  dt 
)
inlinenoexcept

Exponential smoothing: move current toward target at rate smoothing over time step dt.

smoothing is a time constant in seconds: the distance to target falls by a factor of e (to about 37 percent) every smoothing seconds, and halves every 0.69 * smoothing seconds. At smoothing = 0.1 the value tracks quickly; at smoothing = 2.0 it lags heavily.

Framerate-independent. Equivalent to the "lerp every frame" pattern done correctly: current = lerp(current, target, 1 - exp(-dt / smoothing))

Degenerate case (smoothing <= 0) snaps to target immediately.

Definition at line 143 of file Scalar.hpp.

144{
145 if (smoothing <= T { 0 })
146 return target;
147 return current + (target - current) * (T { 1 } - std::exp(-dt / smoothing));
148}
glm::vec2 current

References current.

Referenced by damp_asymmetric().

+ Here is the caller graph for this function: