#Calculating vertices in a hexagonal grid

1 messages · Page 1 of 1 (latest)

stoic ledge
#

Hi, I am looking to find a formula to calculate the number of vertices in a hexagon grid. I can't seem to find a pattern to how hexagonal count affects the number of vertices.

Is there a formula to determine vertice count so I may determine my vertices array size for my mesh or would the best way be to iterate through every hex and determine neighbouring hexagons to calculate vertex count?

rocky basin
#

@stoic ledge
If not mistaken, it will be:
Hexagons:
1 + 3 * r * (r +1)
Vertices:
6 * (1 + r * (r + 2))
I'm not sure what the value in brackets means.

Keep in mind that these formulas will work only for a particular shape type from your example. For other kinds of shapes, such as triangles or rectangles, you would need to reinvent the formulas.

stoic ledge
rocky basin
# stoic ledge Thank you so much. Is there a place to find such formulas or did you manage to w...

It's about noticing patterns. The shape you provided consists of 6 "triangles" that scale with radius. The formula for 1 + 2 + 3 + ... + n pattern is n * (n + 1) / 2. If we multiply this formula by 6 and add 1, we get the total hex count. If we reduce n by 1 and multiply it by 12, we will get the count of brown dots. If we multiply r by 6 * 3, we will end up with the white dot count. After summing both results with 6 dots from the middle hex, you will end up with the vertices formula.

stoic ledge