use super::PhysPol; use super::PhysVec; #[derive(Debug, Clone, Copy)] pub enum Position { Cartesian(PhysVec), Polar(PhysPol), } impl Position { pub fn new_cartesian(x: f64, y: f64) -> Self { return Self::Cartesian(PhysVec { x, y }); } pub fn new_polar(center: PhysVec, radius: f64, angle: f64) -> Self { return Self::Polar(PhysPol { center, radius, angle, }); } /* pub fn to_polar(&self) -> Self { match self { Self::Cartesian(pv) => Self::Polar(pv.to_polar()), Self::Polar(_) => self.clone(), } } */ pub fn to_cartesian(&self) -> Self { match self { Self::Cartesian(_) => self.clone(), Self::Polar(pp) => Self::Cartesian(pp.to_cartesian()), } } } impl Into for Position { fn into(self) -> PhysVec { let c = self.to_cartesian(); match c { Self::Cartesian(pv) => pv, _ => unreachable!(), } } }