// import float
use crate::config::Float;

/// Calculate Velocity
///
/// Velocity formula
/// $$v = \frac{s}{t}$$
///
/// ## Parameter
/// * 'distance' with unit m
/// * 'time' with unit s
/// red note : for time == 0, return 0
pub fn velocity_formula(distance: Float, time: Float) -> Float {
    if time == 0.0 {
        return 0.0;
    }
    distance / time
}

pub trait Velocity {
    fn get_distance(&self) -> Float;
    fn get_time(&self) -> Float;

    fn calculate_velocity(&self) -> Float {
        let time = self.get_time();
        if time == 0.0 {
            0.0
        } else {
            self.get_distance() / time
        }
    }
}
