7
$\begingroup$

There are a lot of answers for how to make a hexagonal mesh on a 3D surface but nothing on how to make a hexagonal mesh on a 2D surface. Can any provide code on how to do so? I am new to mathematica, and it is not so easy to simply convert the 3D hexagonal mesh code in Create hexagonal mesh on 3D Parametric Plot and 3D spheres? or Hexagonal Mesh on a 3D surface to th 2D case.

I have been able to do

Ω = ImplicitRegion[True, {{x, 0, 10}, {y, 0, 10}}];

mesh = ToElementMesh[Ω];

but that is easy. I'd like to be able to mesh anything from a graphics region of the sort Ω to a parametric region like

Θ = ParametricPlot[a {Cos[t], Sin[t]}, {a, 1, 2}, {t, 0, 2 Pi}];

If someone can please provide assistance, it would be much appreciated!

$\endgroup$
  • $\begingroup$ You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. You may also find this this meta Q&A helpful $\endgroup$ – Michael E2 Mar 8 '16 at 23:28
  • 1
    $\begingroup$ Note that polygons are not valid mesh element in an ElementMesh. They are valid for MeshRegion, though. $\endgroup$ – Michael E2 Mar 9 '16 at 0:40
  • $\begingroup$ @nycguy92 Your formulations are not mathematically correct: "...hexagonal mesh on a 3D surface.." -> hexagonal mesh on a 2D manifold embedded in 3D space. There is no such thing as "3D hexagonal mesh". Mesh is per definition a 2D object. $\endgroup$ – yarchik Mar 9 '16 at 9:43
10
$\begingroup$

Altering R.M.'s hexTile slightly, we get what is sought:

hexTile[n_, m_] := 
 With[{hex = Polygon[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}]];

Graphics[{EdgeForm[Black], Yellow, hexTile[20, 20]}]

Mathematica graphics

See R.M.'s answer to Create a torus with a hexagonal mesh for 3D-printing for the defintion of hexTile, which is the function used in kglr's answer to Hexagonal Mesh on a 3D surface that the OP linked.

$\endgroup$

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.