Add utils for hexagonal grild #50

Merged
tipragot merged 23 commits from hex-utils into main 2024-02-14 17:49:08 +00:00
Showing only changes of commit d44db4fa3e - Show all commits

View file

@ -4,7 +4,8 @@ use std::collections::HashSet;
use std::ops;
/// Hexagonal position (in a hexagonal grid).
/// We are using the axial coordinate system explained in this [documentation](https://www.redblobgames.com/grids/hexagons/#coordinates).
/// We are using the axial coordinate system explained in this
/// [documentation](https://www.redblobgames.com/grids/hexagons/#coordinates).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct HexPosition {
/// Q coordinate
@ -19,7 +20,8 @@ impl HexPosition {
///
/// # How does it work ?
///
/// Hexagonal grid using the [cube](https://www.redblobgames.com/grids/hexagons/#coordinates) coordinate system,
/// Hexagonal grid using the
/// [cube coordinate system](https://www.redblobgames.com/grids/hexagons/#coordinates),
/// is like a cube in 2D space.
/// The Manhattan distance between two positions is equal to: the half of
/// the sum of abs(dx) + abs(dy) + abs(dz)