Skip to main content

Module interpolator

Module interpolator 

Source
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 optional max_speed clamp.
  • 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§

SpringFollower
Critically-damped spring follower for a 1D scalar.
SpringFollower3
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 value from 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.