Skip to main content

collision_energy_loss_1d

Function collision_energy_loss_1d 

Source
pub fn collision_energy_loss_1d(
    mass_a: f64,
    velocity_a: f64,
    mass_b: f64,
    velocity_b: f64,
    coefficient_of_restitution: f64,
) -> Option<f64>
Expand description

Computes the total kinetic energy lost in a one-dimensional collision.

This computes the initial and final total kinetic energy and returns the non-negative loss.

ยงExamples

use use_collision::collision_energy_loss_1d;

let loss = collision_energy_loss_1d(1.0, 1.0, 1.0, -1.0, 0.0).unwrap();

assert!((loss - 1.0).abs() < 1.0e-12);