#gamedev #graphics #sphere #math #hexagons

hexasphere

A library to evenly tile hexagons on a sphere

19 stable releases (8 major)

8.0.0 Nov 5, 2022
7.2.1 Sep 2, 2022
7.2.0 Jul 3, 2022
7.0.0 Feb 21, 2022
0.1.7 Aug 25, 2020

#23 in Math

Download history 11061/week @ 2022-08-11 10465/week @ 2022-08-18 10288/week @ 2022-08-25 10331/week @ 2022-09-01 11015/week @ 2022-09-08 8877/week @ 2022-09-15 8919/week @ 2022-09-22 10025/week @ 2022-09-29 11295/week @ 2022-10-06 8038/week @ 2022-10-13 7944/week @ 2022-10-20 11156/week @ 2022-10-27 11845/week @ 2022-11-03 16734/week @ 2022-11-10 12948/week @ 2022-11-17 7130/week @ 2022-11-24

50,381 downloads per month
Used in 355 crates (2 directly)

MIT/Apache

92KB
2K SLoC

hexasphere

Library for subdividing shapes, such as an icosahedron. This provides abstractions for almost anything to be possible, however there are many predetermined shapes.

In the case of the icosphere:

Geometry:

This starts off with an icoashedron, and then proceeds to subdivide it. The subdivided points form the dual to a goldberg polyhedron. In essence, each point on this sphere is either a hexagon or a pentagon.

Interpolation:

Points are interpolated using the geometric slerp function to preserve their accuracy.


Features

  • Base shapes
    • Icosahedron
    • Tetrahedron
    • Triangle
    • Square
    • Cube
  • Interpolation functions
    • Spherical interpolation
    • Linear interpolation
    • Normalized linear interpolation
  • Basic optimizations for p == 0.5 in interpolation.
  • An adjacency (neighbour) map which can be generated from the indices that this library creates.

A few more optimizations are coming, along with more options for generation:

  • Remove nested triangle layers by placing them into their own Vec.
  • Allow interpolation functions to have access to state. (This would permit certain things such as sampling noise as part of the generation).

License

Hexasphere is distributed under the terms of either the MIT license, or the Apache License (Version 2.0) at the user's choice.

See the files named LICENSE-MIT and LICENSE-APACHE2 relative to the root directory of this project for more details.

Dependencies

~2MB
~51K SLoC