How can I include hexagonal meshing on a Plot3D
such as this?
Plot3D[Sin[x], {z, -3, 3}, {x, -4 \[Pi], 4 \[Pi]}]
How can I include hexagonal meshing on a Plot3D
such as this?
Plot3D[Sin[x], {z, -3, 3}, {x, -4 \[Pi], 4 \[Pi]}]
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[#] &]
plot3DwHexMesh[Sin[# + #2] &, 20, 20,
Directive[Orange, Opacity[0.8], Specularity[White, 30]], Boxed -> False]
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$
False
as the default option value for Axes
:)
$\endgroup$