pub fn collision_impulses_1d(
mass_a: f64,
velocity_a: f64,
mass_b: f64,
velocity_b: f64,
coefficient_of_restitution: f64,
) -> Option<(f64, f64)>Expand description
Computes the impulses on both bodies for a one-dimensional collision.
This computes the final velocities with collision_final_velocities_1d and then returns the
impulse on A and the impulse on B.
ยงExamples
use use_collision::collision_impulses_1d;
let (impulse_a, impulse_b) = collision_impulses_1d(1.0, 1.0, 1.0, -1.0, 1.0).unwrap();
assert!((impulse_a + 2.0).abs() < 1.0e-12);
assert!((impulse_b - 2.0).abs() < 1.0e-12);