Message Boards Message Boards

GROUPS:

Draw 2D Hexagon to 3D Hexagon prism, or Thick Hexagon Mesh?

Posted 8 months ago
1043 Views
|
5 Replies
|
2 Total Likes
|

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?

Attachments:
POSTED BY: Arm Mo
Answer
5 Replies

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:

enter image description here

Regards -- Henrik

Posted 8 months ago

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 ?

POSTED BY: Arm Mo
Answer

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:

enter image description here

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}]]

enter image description here

Hope that helps, regards -- Henrik

hi, I would like to knoww how do I elaborate a fractal hexagon including manipulate. Help me please.

Posted 4 months ago

Thx Henrik, the best solution 1 1

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract