1

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

Plot3D[Sin[x], {z, -3, 3}, {x, -4 \[Pi], 4 \[Pi]}]
David G. Stork
  • 41,180
  • 3
  • 34
  • 96
some
  • 13
  • 2
  • You may be able to use the answers from here: https://mathematica.stackexchange.com/q/39879/9490 – Jason B. Jan 23 '18 at 18:37
  • I saw that, but I couldn't use that because that was used for graphic plot 3d and my plot is not graphic plot – some Jan 23 '18 at 18:49
  • I think its fair to say there is not a straightforward way to do this for a general function. – george2079 Jan 23 '18 at 20:48
  • This is a step in the right direction: https://pastebin.com/raw/NtSmn50x , based off the answer here: https://mathematica.stackexchange.com/q/77312/9490 – Jason B. Jan 23 '18 at 20:59

1 Answers1

3

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

kglr
  • 394,356
  • 18
  • 477
  • 896
  • 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. – Jason B. Jan 23 '18 at 21:32
  • @JasonB, right; I was puzzling over exactly those challenges. Not easy. Hence False as the default option value for Axes:) – kglr Jan 23 '18 at 21:40