use nalgebra::{convert, RealField};
use simba::scalar::SubsetOf;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Scale<N: Copy + RealField> {
den: N,
}
impl<N: Copy + RealField> Default for Scale<N> {
fn default() -> Self {
Self {
den: convert(120.0),
}
}
}
impl<N: Copy + RealField> Scale<N> {
#[must_use]
pub fn compute(&self, num: N) -> N {
N::one() - num / self.den
}
#[must_use]
pub const fn denominator(&self) -> N {
self.den
}
pub fn set_denominator(&mut self, den: N) {
self.den = den;
}
#[must_use]
pub fn cast<M: Copy + RealField>(self) -> Scale<M>
where
N: SubsetOf<M>,
{
Scale {
den: self.den.to_superset(),
}
}
}