1
$\begingroup$

How can I include hexagonal meshing on a Plot3D such as this?

Plot3D[Sin[x], {z, -3, 3}, {x, -4 \[Pi], 4 \[Pi]}]
$\endgroup$
2
$\begingroup$

Using rm-rf's hextile yet again

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}] /. 
    {x_?NumericQ, y_?NumericQ} :> 2 π {x/(3 m), 2 y/(n Sqrt[3])}

ClearAll[plot3DwHexMesh]
plot3DwHexMesh[f_, n_: 20, m_: 20, s_: Yellow, o : OptionsPattern[]] :=
  Graphics3D[hexTile[n, m] /. Polygon[l_] :> 
    {s, Polygon[l], Polygon[{Pi/5, 0} + {-1, 1} # & /@ l]} /. 
   Polygon[l_List] :> Polygon[{#, #2, f[#, #2]} & @@@ l], o, 
  Axes -> False, PlotRange -> All, Lighting -> "Neutral"]

Examples:

plot3DwHexMesh[Sin[#] &]

enter image description here

plot3DwHexMesh[Sin[# + #2] &, 20, 20, 
 Directive[Orange, Opacity[0.8], Specularity[White, 30]],  Boxed -> False]

enter image description here

$\endgroup$
  • $\begingroup$ The problem with this, and every variant I tried using hexTile, is that I couldn't find a way to respect the original PlotRange. plot3DwHexMesh should, ultimately, take the x and y range into consideration, and show the Axes with the correct values. $\endgroup$ – Jason B. Jan 23 '18 at 21:32
  • $\begingroup$ @JasonB, right; I was puzzling over exactly those challenges. Not easy. Hence False as the default option value for Axes:) $\endgroup$ – kglr Jan 23 '18 at 21:40

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.