An open API service indexing awesome lists of open source software.

https://github.com/erinpentecost/hex

Hexagonal grid math library.
https://github.com/erinpentecost/hex

grid hex hexagonal

Last synced: 2 months ago
JSON representation

Hexagonal grid math library.

Awesome Lists containing this project

README

          

![hex logo](examples/drawhx/TestDrawLogo.png)

[![Go Report Card](https://goreportcard.com/badge/github.com/erinpentecost/hexcoord)](https://goreportcard.com/report/github.com/erinpentecost/hexcoord)
[![Travis CI](https://travis-ci.org/erinpentecost/hexcoord.svg?branch=master)](https://travis-ci.org/erinpentecost/hexcoord.svg?branch=master)
[![GoDoc](https://godoc.org/github.com/erinpentecost/hexcoord?status.svg)](https://godoc.org/github.com/erinpentecost/hexcoord)

hex is a Go implementation of hexagonal grid math based on amitp's *Hexagonal Grids* articles. This package focuses on hexagonal grid math, including:

* Generating sets of hexes programmatically in common patterns.
* Compositing sets of hexes with unions, intersections, and subtractions (constructive solid geometry).
* Multithreaded A* pathing in a hex grid.
* Fast intersection testing.
* Super naive [drawing package](examples/drawhx)! This isn't performant; it's to help you visualize what's going on.

```go
import (
// Base library
"github.com/erinpentecost/hex"
// For pathfinding
"github.com/erinpentecost/hex/path"
// For constructive solid geometry
"github.com/erinpentecost/hex/area"
)
```

![hex map](examples/drawhx/testdraw.png)

## References

* [Hexagonal Grids](https://www.redblobgames.com/grids/hexagons)
* [Implementation of Hex Grids](https://www.redblobgames.com/grids/hexagons/implementation.html)
* [Priority Queue](https://golang.org/pkg/container/heap/#example__priorityQueue)
* [Constructive solid geometry (CSG)](https://en.wikipedia.org/wiki/Constructive_solid_geometry)
* [GLTF](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes)
* [More GLTF](https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_005_BuffersBufferViewsAccessors.md)