Skip to main content

hex_predict_grid_position

Function hex_predict_grid_position 

Source
pub fn hex_predict_grid_position(
    grid: &HashMap<GridIndex, Point2<f32>>,
    idx: GridIndex,
) -> Option<Point2<f32>>
Expand description

Predict a hex grid corner’s position from its neighbors along three axes.

Uses midpoint averaging on up to three opposite-direction pairs:

  • E/W: midpoint of (q-1, r) and (q+1, r)
  • NE/SW: midpoint of (q+1, r-1) and (q-1, r+1)
  • NW/SE: midpoint of (q, r-1) and (q, r+1)

Returns the average of available predictions, or None if no complete neighbor pair exists.