Skip to content

rodonn/Hexagons.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hexagons

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 points(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 pointhex function.

h = pointhex(23.5, 4.67)

Status

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

About

Useful tools for working with hexagonal grids

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Julia 100.0%