pub trait Distance {
fn dist(&self, other: &Self) -> u8;
}
fn dist(&self, other: &Self) -> u8
Return the grid distance from self
to other
.
Loading content...
use bestagon::{coords::Axial, distance::Distance};
assert_eq!(Axial(0, 4).dist(&Axial(1, 2)), 2);
assert_eq!(Axial(-3, 2).dist(&Axial(3, -1)), 6);
use bestagon::{coords::Cube, distance::Distance};
assert_eq!(Cube(0, 4, -4).dist(&Cube(1, 2, -3)), 2);
assert_eq!(Cube(-3, 2, 1).dist(&Cube(3, -1, -2)), 6);
assert_eq!(Cube(-4, 4, 0).dist(&Cube(4, -4, 0)), 8);
Loading content...