2
$\begingroup$

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]

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Are you trying to find the hexagonal lattice points that fall in the convex hull region? $\endgroup$ – flinty Jun 25 '20 at 16:27
  • $\begingroup$ 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. $\endgroup$ – Lucas Lopes Jun 25 '20 at 16:30
1
$\begingroup$

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}}]

lattice points

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.