pub fn spring_damper(
hertz: f32,
damping_ratio: f32,
position: f32,
velocity: f32,
time_step: f32,
) -> f32Expand description
One-dimensional mass-spring-damper simulation. Returns the new velocity given the position and time step. You can then compute the new position using: position += time_step * new_velocity This drives towards a zero position. By using implicit integration we get a stable solution that doesn’t require transcendental functions.