generated from tipragot/rust
Add utils for hexagonal grild #50
|
@ -21,7 +21,8 @@ impl HexPosition {
|
|||
///
|
||||
/// Hexagonal grid using the [cube](https://www.redblobgames.com/grids/hexagons/#coordinates) coordinate system,
|
||||
/// 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)
|
||||
/// The Manhattan distance between two positions is equal to: the half of
|
||||
/// the sum of abs(dx) + abs(dy) + abs(dz)
|
||||
///
|
||||
/// # Example:
|
||||
///
|
||||
|
@ -47,11 +48,13 @@ impl HexPosition {
|
|||
(dq.abs() + dr.abs() + ds.abs()) as f32 / 2.
|
||||
}
|
||||
|
||||
/// Returns all positions within a given `range` from the current HexPosition.
|
||||
/// Returns all positions within a given `range` from the current
|
||||
/// HexPosition.
|
||||
///
|
||||
/// This function iterates over the possible q and r values within the specified range
|
||||
/// and inserts HexPositions into a HashSet, ensuring that each generated position
|
||||
/// is within the given range from the current position.
|
||||
/// This function iterates over the possible q and r values within the
|
||||
/// specified range and inserts HexPositions into a HashSet, ensuring
|
||||
/// that each generated position is within the given range from the
|
||||
CoCo_Sol marked this conversation as resolved
Outdated
|
||||
/// current position.
|
||||
///
|
||||
/// for more details: https://www.redblobgames.com/grids/hexagons/#range
|
||||
///
|
||||
|
@ -75,7 +78,6 @@ impl HexPosition {
|
|||
}
|
||||
result_positions
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl ops::Add<HexPosition> for HexPosition {
|
||||
|
|
Loading…
Reference in a new issue
dz = -dq - dr