pub fn damp_vec3(
current: Vec3,
target: Vec3,
rate: f32,
dt: f32,
) -> Result<Vec3, MotionError>Expand description
Exponentially approach a 3D target without overshoot.
This is the 3D counterpart of damp_vec2, with identical validation,
inverse-second rate, finite output and floating-point limits. Pass a zero
target to damp velocity; use approach_vec3 to bound acceleration instead.
use ferravex_math::Vec3;
use ferravex_play::motion::damp_vec3;
let velocity = damp_vec3(Vec3::new(8., -4., 2.), Vec3::ZERO,
std::f32::consts::LN_2, 1.)?;
assert!(velocity.abs_diff_eq(Vec3::new(4., -2., 1.), 1e-6));