use std::fmt::{Display, Formatter, Result}; use std::ops::{Add, Sub, AddAssign, SubAssign, Div, Mul, DivAssign, MulAssign}; use crate::metric::Unit; use crate::metric::Primitive; use crate::declare_unit_basics; #[derive(Copy, Clone, Debug, PartialOrd, PartialEq)] pub enum PlaneAngle { Base(f64, fn(f64) -> f64, &'static str), Canonical(f64), Radian(f64), Degree(f64), } impl Unit for PlaneAngle { fn to_si_unit(&self) -> PlaneAngle { match self { PlaneAngle::Base(_, _, _) => self.clone(), PlaneAngle::Canonical(value) => PlaneAngle::Base(value.clone(), |x| x, "m²"), PlaneAngle::Radian(value) => PlaneAngle::Base(value.clone(), |x| x, "rad"), PlaneAngle::Degree(value) => PlaneAngle::Base(value * std::f64::consts::PI / 180.0, |x| x / std::f64::consts::PI * 180.0, "°"), } } } declare_unit_basics!(PlaneAngle);