ramoh87
(Arm Mo)
February 24, 2018, 2:10am
1
So I tried this code for 2D, but I would like to have say a slab with a defined thickness not just a plane,
The code for 2D is:
h[x_, y_] :=
Polygon[Table[{Cos[2 Pi k/6] + x, Sin[2 Pi k/6] + y}, {k, 6}]];
Graphics[{EdgeForm[Opacity[.7]], LightBlue,
Table[h[3 i + 3 ((-1)^j + 1)/4, Sqrt[3]/2 j], {i, 10}, {j, 15}]}]
I also found and modified this code Here but this is a very thin sheet , I would like to be able to define a thickness to it:
Graphics3D[
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, 10}, {j,
15}]] /.
Polygon[l_] :> {Red, Polygon[l], Polygon[{1, 0} # & /@ l]} /.
Polygon[l_List] :> Polygon[top @@@ l], Boxed -> False,
Axes -> False, PlotRange -> All, Lighting -> "Neutral"]
Can you help me how to convert 2D hexagonal to 3D hexagonal slab with user defined thickness?
Here comes just a “quick and dirty” option - but short at least:
h3D[x_, y_, r_] := Tube[Table[{Cos[2 Pi k/6] + x, Sin[2 Pi k/6] + y, 0}, {k, 7}], r]
Graphics3D[{Table[h3D[3 i + 3 ((-1)^j + 1)/4, Sqrt[3]/2 j, .3], {i, 10}, {j, 15}]}]
which gives:
Regards – Henrik
ramoh87
(Arm Mo)
February 24, 2018, 10:40pm
3
Thanks a lot, but this is not what I want. I want the 3D Hexagon Prisms. Or at least is there away to modify this to change from round tubes to 3d hexagons packed next to each other ?
Ok, ok, you are absolutely right! Here comes a somewhat cleaner solution:
hexPts[x_, y_] := Table[{Cos[2 Pi k/6] + x, Sin[2 Pi k/6] + y}, {k, 7}]
hexConns[x_, y_] := Partition[hexPts[x, y], 2, 1]
wall[h_][{{x1_, y1_}, {x2_, y2_}}] := Polygon[{{x1, y1, 0}, {x2, y2, 0}, {x2, y2, h}, {x1, y1, h}}]
hex3D[h_][x_, y_] := wall[h] /@ hexConns[x, y]
Graphics3D[Table[hex3D[2][3 i + 3 ((-1)^j + 1)/4, Sqrt[3]/2 j], {i, 10}, {j, 15}]]
This now gives:
The hight of the hexagons can be chosen individually:
Graphics3D[Table[hex3D[RandomReal[3]][3 i + 3 ((-1)^j + 1)/4, Sqrt[3]/2 j], {i, 10}, {j, 15}]]
Hope that helps, regards – Henrik
anatrejos
(Ana Sofia Trejos Vanegas)
April 30, 2018, 4:58pm
5
hi, I would like to knoww how do I elaborate a fractal hexagon including manipulate. Help me please.
Thx Henrik, the best solution