use num_traits::{Float, One, Zero};
use std::ops::{Add, Mul};
pub fn lerp<T, U>(a: T, b: T, amount: U) -> T
where
T: Add<Output = T> + Mul<U, Output = T>,
U: Float + One,
{
a * (U::one() - amount) + b * amount
}
pub fn bounded_lerp<T, U>(a: T, b: T, amount: U) -> T
where
T: Add<Output = T> + Mul<U, Output = T>,
U: Float + Zero + One,
{
lerp(
a,
b,
match amount {
amount if amount < U::zero() => U::zero(),
amount if amount > U::one() => U::one(),
amount => amount,
},
)
}