hexagon_map/point/a_point.rs
1use super::*;
2
3/// A point in 3D stepped coordinate
4/// s = - q - r
5#[derive(Copy, Clone, Ord, PartialOrd, Eq, Hash, Serialize, Deserialize)]
6pub struct AxialPoint {
7 /// The horizontal axis
8 /// - `T`: move to right
9 /// - `F`: move to left
10 pub q: isize,
11 /// The right up axis
12 /// - `T`: move to right up
13 /// - `F`: move to left down
14 pub r: isize,
15}
16
17impl AxialPoint {
18 pub fn new(q: isize, r: isize) -> Self {
19 Self { q, r }
20 }
21 pub fn go(&self, direction: Orientation) -> Self {
22 <AxialPoint as Into<CubicPoint>>::into(*self).go(direction).into()
23 }
24}