hexagon_map/point/
w_point.rs

1use super::*;
2
3/// A point in 3D stepped coordinate
4#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
5pub struct WPoint {
6    /// Q-axis index, Z-axis index in cube coordinates
7    pub x: isize,
8    /// S-axis index, X-axis index in cube coordinates
9    pub y: isize,
10}
11
12impl WPoint {
13    pub fn new(x: isize, y: isize) -> Self {
14        Self { x, y }
15    }
16    pub fn go(&self, direction: Orientation) -> Self {
17        <WPoint as Into<CubicPoint>>::into(*self).go(direction).into()
18    }
19}
20
21impl From<CubicPoint> for WPoint {
22    fn from(point: CubicPoint) -> Self {
23        WPoint::new(point.p, point.q)
24    }
25}
26
27impl Into<CubicPoint> for WPoint {
28    fn into(self) -> CubicPoint {
29        CubicPoint::new(self.x, self.y)
30    }
31}