pub fn bin_hexagonal(
x: &[f64],
y: &[f64],
gridsize: usize,
mincnt: usize,
) -> HexBinResultExpand description
Bins (x, y) data points into a flat-top hexagonal grid.
The grid is sized so that roughly gridsize hexagons span the x-extent
of the data. Only cells with at least mincnt points are included in
the result.
§Algorithm
Uses the standard “nearest hex center” approach for flat-top hexagons:
- Compute hex size (circumradius) from the data extent and
gridsize. - For each point, convert to fractional axial coordinates then round to the nearest hex cell using cube-coordinate rounding.
- Accumulate counts in a hash map keyed by axial
(q, r). - Convert each cell’s axial coordinates back to Cartesian centers.