Expand description
Motion interpolation — smooth damp, exponential decay, spring followers. Motion interpolation — smooth damp, exponential decay, spring followers, and scalar / vector utility functions.
§Functions
smooth_damp/smooth_damp3— Unity-style critically-damped smoothing with velocity output and optionalmax_speedclamp.exp_decay/exp_decay3— Simple exponential decay (no velocity tracking; cheaper than smooth damp).lerp,lerp3,remap,smoothstep,smootherstep— scalar and vector utilities.
§Types
SpringFollower— critically-damped spring that tracks a 1D target.SpringFollower3— same for a[f64; 3]target.
§Example
use oxiphysics::interpolator::{smooth_damp, SpringFollower};
let mut vel = 0.0_f64;
let out = smooth_damp(0.0, 10.0, &mut vel, 0.2, f64::INFINITY, 0.016);
assert!(out > 0.0 && out < 10.0);
let mut spring = SpringFollower::new(100.0);
let pos = spring.update(5.0, 0.016);
assert!(pos > 0.0);Structs§
- Spring
Follower - Critically-damped spring follower for a 1D scalar.
- Spring
Follower3 - Critically-damped spring follower for a
[f64; 3]vector.
Functions§
- exp_
decay - Exponential decay toward
target:current + (target − current)(1 − e^(−rate·dt)). - exp_
decay3 - Exponential decay for
[f64; 3]. - lerp
- Linear interpolation:
a + t*(b−a). - lerp3
- Linear interpolation for
[f64; 3]vectors. - remap
- Remap
valuefrom range[in_min, in_max]to[out_min, out_max]. - smooth_
damp - Unity-style smooth damp — critically-damped spring with velocity continuity.
- smooth_
damp3 - Smooth damp for
[f64; 3]vectors. - smootherstep
- Quintic smootherstep:
6t⁵ − 15t⁴ + 10t³(zero first and second derivatives at 0 and 1). - smoothstep
- Cubic Hermite smoothstep:
3t² − 2t³, clamped input.