Reputation: 2543
I want to create a hexagonal lattice but it should be centered basically the whole lattice is a central hexagon and then layers of hexagon around, like shown in the figure. (may be my description is confusion, but right now that is how I am seeing it).
So I want to generate the coordinates for lattice below. I found many algorithm to create square lattice of hexagons but I want to ask if there is a algorithm for following lattice too.
Upvotes: 1
Views: 1312
Reputation: 80287
Note:
N-th layer consists of 6N cells.
First cell of that layer in your representation has coordinate shift
(N*A*Sqrt(3)/2, N*A*3/2), where A is edge length.
First cell of that layer has number
2+3*N*(N-1) //(you have missed 14)
You can start from the first cell of Nth layer, make N more cells to left, N cells to left-down and so on...
Upvotes: 1