# Generating points inside convexhullmesh

How could I generate these points

hexagon={{0, Sqrt[3]/2}, {1/2, Sqrt[3]}, {3/2, Sqrt[3]}, {2, Sqrt[3]/2}, {3/2,
0}, {1/2, 0}}


following this rule

pts[x_, y_] := Flatten[Table[{{3 j, Sqrt[3] k}}, {j, 1, x}, {k, 0, y}], 2]];


but inside this region

ConvexHullMesh[{t1, t2, t1 + t2, {0, 0}}]


where

m = 1.;
n = m + 1;
a1 = {Sqrt[3]/2, -1/2}*Sqrt[3];
a2 = {Sqrt[3]/2, 1/2}*Sqrt[3];
t1 = m*a1 + n*a2;
t2 = (n + m)*a1 - m*a2;


I tried to use something like this

totalpoints=TranslationTransform[# - hexagon[[1]]][hexagon] & /@
pts[somesize, somesize];


And then I cut inside the region doing this

pointsinsideregion =
Table[If[RegionMember[
ConvexHullMesh[{t1, t2, t1 + t2, {0, 0}}], totalpoints[[u]]],
totalpoints[[u]], Nothing], {u, 1, totalpoints[Upp]}]


The problem is that I use more points that is necessary (in function pts[x,y] where somesize i get usually in terms of "m") to the calculation.

Maybe the solution is something using regionmember with the function pts[x,y]

. . . Just to illustrate

eta = Graphics[{EdgeForm[Thickness[0.001]], PointSize[0.009], Blue,
Point /@ TranslationTransform[# - hexagon[[4]]][hexagon] & /@
pts[5, 5]}];
Show[ConvexHullMesh[{t1, t2, t1 + t2, {0, 0}} + 4 m], eta,
Frame -> True, PlotRange -> Full]


• Are you trying to find the hexagonal lattice points that fall in the convex hull region? – flinty Jun 25 '20 at 16:27
• Yes, like in the illustration, I want the points inside, not in the vertices for example. You can see that I need to move the region by 4*m to fit them inside. – Lucas Lopes Jun 25 '20 at 16:30

Use RegionMember. Also consider using CirclePoints rather than generating the hexagon coordinates manually. I've used DeleteDuplicates to get rid of overlapping points too:

m = 1.;
n = m + 1;
a1 = {Sqrt[3]/2, -1/2}*Sqrt[3];
a2 = {Sqrt[3]/2, 1/2}*Sqrt[3];
t1 = m*a1 + n*a2;
t2 = (n + m)*a1 - m*a2;
hexagon = CirclePoints[6];
pts[x_, y_] := # + {x, y} & /@ CirclePoints[6]
reg = ConvexHullMesh[{t1, t2, t1 + t2, {0, 0}}];
lattice =
DeleteDuplicates@
Flatten[Table[
pts[3 x/2, Sqrt[3] y + 3 Sqrt[3]/2 x], {x, -1, 5}, {y, -10, 0}],
2];
inside = Select[lattice, RegionMember[reg, #] &];
Graphics[{Gray, reg, Red,
Point[lattice],
Blue, Point[inside]
}, Frame -> True, PlotRange -> {{-1, 8}, {-5, 4}}]


• It's not clear what m was for, I'm sure you can adapt this with little difficulty. – flinty Jun 25 '20 at 16:52
• m works to change the size of the region, if I use m=2 in your code for example, the region becomes incomplete. – Lucas Lopes Jun 25 '20 at 17:56
• @LucasLopes did this solve your problem? – flinty Jul 8 '20 at 12:43