# Hexagonal lattice points with center points in 2D

I am using the follwing coder from here, answered by Michael E2, to create 2d lattice points, without the center ponts of the cells.

hexTile[n_, m_] :=
With[{hex =
Table[{Cos[2 Pi k/6] + #, Sin[2 Pi k/6] + #2}, {k, 6}] &},
Table[hex[3 i + 3 ((-1)^j + 1)/4, Sqrt[3]/2 j], {i, n}, {j, m}]];
factor = 12;
coordinates = Flatten[hexTile[4, 10], 2]*factor;
ListPlot[coordinates, AspectRatio -> Automatic]


One problem here is that double coordinates are produced, which I don't need:

Length@coordinates
240

Length@DeleteDuplicates@coordinates
106


How can I modify the function hexTile[n_, m_] that no double coordinates are produced and how can I add center points to the hexagonal cells?

• Possible duplicate of How to create an hexagonal lattice structure May 7, 2019 at 12:45
• A honeycomb lattice with the centers filled in is also called a triangular lattice; the question becomes what do you want to do about the boundaries? May 7, 2019 at 13:06

try this

hexTile[n_,m_]:=With[{hex=Join[t=Table[{Cos[2 Pi k/6]+#,Sin[2 Pi k/6]+#2},{k,6}],
{Median@t}]&},Table[hex[3 i+3 ((-1)^j+1)/4,Sqrt[3]/2 j],{i,n},{j,m}]];
factor=12;
coordinates=Union@Flatten[hexTile[4,10],2]*factor;
ListPlot[coordinates,AspectRatio->Automatic]


• Please see my updated question. Do you know why there are a lot of duble coordinates produced? I find for your solutionLength@coordinates = 280 and Length@DeleteDuplicates@coordinates = 146
– lio
May 14, 2019 at 16:24
• @lio I fixed the algorithm. now everything is fine May 14, 2019 at 16:52