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$
4
  • $\begingroup$ You may be able to use the answers from here: mathematica.stackexchange.com/q/39879/9490 $\endgroup$
    – Jason B.
    Commented Jan 23, 2018 at 18:37
  • $\begingroup$ I saw that, but I couldn't use that because that was used for graphic plot 3d and my plot is not graphic plot $\endgroup$
    – some
    Commented Jan 23, 2018 at 18:49
  • $\begingroup$ I think its fair to say there is not a straightforward way to do this for a general function. $\endgroup$
    – george2079
    Commented Jan 23, 2018 at 20:48
  • $\begingroup$ This is a step in the right direction: pastebin.com/raw/NtSmn50x , based off the answer here: mathematica.stackexchange.com/q/77312/9490 $\endgroup$
    – Jason B.
    Commented Jan 23, 2018 at 20:59

1 Answer 1

4
$\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$
2
  • $\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.
    Commented Jan 23, 2018 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
    Commented Jan 23, 2018 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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