use mint::Point2; pub struct IsometricVector2(Point2); impl IsometricVector2 { pub fn x(&self) -> f32 { self.0.x } pub fn y(&self) -> f32 { self.0.y } } impl From> for IsometricVector2 { fn from(cart: Point2) -> IsometricVector2 { let x = cart.x - cart.y; let y = (cart.x + cart.y) / 2.0; IsometricVector2(Point2 { x, y }) } } impl Into> for IsometricVector2 { fn into(self) -> Point2 { let x = (2.0 * self.y() + self.x()) / 2.0; let y = (2.0 * self.y() - self.x()) / 2.0; Point2 { x, y } } } impl From<(T, T)> for IsometricVector2 where T: std::convert::Into, { fn from(tuple: (T, T)) -> IsometricVector2 { IsometricVector2(Point2 { x: tuple.0.into(), y: tuple.1.into(), }) } }