# How to obtain the positions of the points in a lattice

I want to know the positions of each point in a hexagon lattice, like I saw some posts where they obtain this lattice using a function

pts[x_, y_] :=
Flatten[Table[{{3 m, \[Sqrt]3 n}, {3 m + 3/2, \[Sqrt]3 n + \[Sqrt]3/
2}}, {m, 0, x}, {n, 0, y}], 2];


And then, converting these points into a lattice, with Polygon, and Points.

Hexagon = {EdgeForm[Thickness[0.01]], Yellow,
Polygon[Table[{Cos[n Pi/3], Sin[n Pi/3]}, {n, 6}]],
PointSize[0.02], Black,
Point /@ Table[{Cos[n Pi/3], Sin[n Pi/3]}, {n, 6}]};
Graphics[Translate[Hexagon, pts[3, 2]]]


But if you look to the function pts[x,y] in ListPlot it doesn't give to you a hexagon lattice pattern.

How can I exhibit a hexagon lattice using ListPlot, and get the {x,y} points? And after that, how can I rotate these points by Pi/2?

Obs; I tried to find some logic using the hexagon geometry. Defining the distance of the nearest points by a0 the second nearest distance between the points will be Sqrt a0

In the OP, the hexagon shape is defined by these points (inside Polygon in the example):

hexpoints = Table[{Cos[n Pi/3], Sin[n Pi/3]}, {n, 6}]

(* {{1/2, Sqrt/2}, {-(1/2), Sqrt/2}, {-1, 0}, {-(1/2), -(Sqrt/2)}, {1/2, -(Sqrt/2)}, {1, 0}} *)


These make a hexagon shape with ListPlot:

ListPlot[hexpoints, PlotStyle -> PointSize[Large], AspectRatio -> Automatic] The pts function in the OP is used to generate the grid on which the pattern repeats.

gridpts = pts[3, 2];


We can then translate the hexagon points to each point in the grid:

hexlattice =
TranslationTransform[# - hexpoints[]][hexpoints] & /@ gridpts

ListPlot[hexlattice, PlotStyle -> PointSize[Large], AspectRatio -> Automatic] • ´´´hexlattice = TranslationTransform[# - hexpoints[]][hexpoints] & /@ gridpts´´´ could you explain what is happening in this line? And how do rotate this set of points around an arbitrary axis? – Lucas Lopes Sep 27 at 0:20
• @LucasLopes TranslationTransform[v] returns a function that can translate points by a vector v. So for each point # in gridpts, we first call TranslationFransform with the vector #-hexpoints[] (I arbitrarily picked the first point in hexpoints - you could pick any of them); then apply that transform function to all of the hexpoints. Another way to write that line is Table[TranslationTransform[pt - hexpoints[]][hexpoints], {pt, gridpts}] – MelaGo Sep 27 at 0:38
• @LucasLopes I think you should open a new question for rotation of points. Cheers – MelaGo Sep 27 at 0:46
• Is there any way to group hexlattice in {{0,0},{1,0},.....} ? Actually is grouped by each hexagon. In the case with pts[1,1] you get {{{},...,{}},{{},.....,{}},....8 times}. – Lucas Lopes Sep 27 at 4:32
• I tried Flatten[TranslationTransform[# - hexpointss[]][hexpointss] & /@ ptss[1, 1], 1] it works well – Lucas Lopes Sep 27 at 4:44