dummy-link

Hexagons

Useful tools for working with hexagonal grids

Readme

Hexagons

Build
Status

This package provides some basic utilities for working with hexagonal grids. It is largely works from Amit Patel's terrific refererence.

Synopsis

Hexagonal grids can be indexed a number of different ways. Indexes are represented with one of the Hexagon types. The following are currently provided:

HexagonAxial(q, r)
HexagonCubic(x, y, z)
HexagonOffsetOddR(q, r)
HexagonOffsetEvenR(q, r)

One indexing system can be converted to another with convert.

convert(HexagonOffsetOddR, HexagonAxial(2, 4))

The six points (in cartesian space) of a hexagon can be iterated through with points.

for (x, y) in vertices(HexagonAxial(2, 3))
    # ...
end

The center point can be obtained with center

x, y = center(HexagonAxial(2, 3))

A point in cartesian space can be mapped to the index of the hexagon that contains it with the cube_round function.

h = cube_round(23.5, 4.67)

Status

This library is not mature or complete, but provides just enough to implement hexagonal bin visualizations. If your hexagon project requires something that's not provided, file bug or pull request.

First Commit

12/26/2013

Last Touched

about 1 month ago

Commits

24 commits

Requires: