use super::util::*;
use core::ops::{Add, Div, Mul, Neg};
use num_traits::{ConstOne, Float};
#[inline(always)]
pub fn height_from_time_and_impulse<N>(time: N, impulse: N) -> N
where
N: ConstOne + Add<Output = N> + Mul<Output = N> + Div<Output = N>,
{
halve(impulse * time)
}
#[inline(always)]
pub fn height_from_time_and_gravity<N>(time: N, gravity: N) -> N
where
N: Copy + ConstOne + Neg<Output = N> + Add<Output = N> + Mul<Output = N> + Div<Output = N>,
{
-halve(gravity * pow2(time))
}
#[inline(always)]
pub fn impulse_from_height_and_gravity<N>(height: N, gravity: N) -> N
where
N: Float,
{
(double(height) * gravity).abs().sqrt()
}
#[inline(always)]
pub fn impulse_from_time_and_gravity<N>(time: N, gravity: N) -> N
where
N: Neg<Output = N> + Mul<Output = N>,
{
-gravity * time
}