Mathematically producing sphere-shaped hexagonal grid

Aaron Franke picture Aaron Franke · Oct 16, 2017 · Viewed 11.2k times · Source

I am trying to create a shape similar to this, hexagons with 12 pentagons, at an arbitrary size.

https://i.stack.imgur.com/F35J0.png

(Image Source)

The only thing is, I have absolutely no idea what kind of code would be needed to generate it!

The goal is to be able to take a point in 3D space and convert it to a position coordinate on the grid, or vice versa and take a grid position and get the relevant vertices for drawing the mesh.

I don't even know how one would store the grid positions for this. Does each "triagle section" between 3 pentagons get their own set of 2D coordinates?

I will most likely be using C# for this, but I am more interested in which algorithms to use for this and an explanation of how they would work, rather than someone just giving me a piece of code.

Answer

hkrish picture hkrish · Nov 23, 2017

The shape you have is one of so called "Goldberg polyhedra", is also a geodesic polyhedra.

The (rather elegant) algorithm to generate this (and many many more) can be succinctly encoded in something called a Conway Polyhedron Notation.

The construction is easy to follow step by step, you can click the images below to get a live preview.

  1. The polyhedron you are looking for can be generated from an isosahedron -- Initialise a mesh with an isosahedron. isosahedron

  2. We apply a "Truncate" operation (Conway notation t) to the mesh (the sperical mapping of this one is a football). enter image description here

  3. We apply the "Dual" operator (Conway notation d). enter image description here

  4. We apply a "Truncate" operation again. At this point the recipe is tdtI (read from right!). You can already see where this is going. enter image description here

  5. Apply steps 3 & 4 repeatedly until you are satisfied.

For example below is the mesh for dtdtdtdtI. enter image description here

This is quite easy to implement. I would suggest using a datastructure that makes it easy to traverse the neighbourhood give a vertex, edge etc. such as winged-edge or half-edge datastructures for your mesh. You only need to implement truncate and dual operators for the shape you are looking for.