Skip to main content
deleted 88 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[triHex];
triHex[w_, h_] := Module[{hex = {FaceForm[White], EdgeForm[Black], Polygon@#, 
   Red, PointSize[Large], Point@#} &@ Table[{Cos[2 Pi k /6], Sin[2 Pi 
 kPolygon /6]},@ {k#, 6}]}Red, 
 Fold[Translate[#,Point {{0,@ 0#}, ## & @@@ #2CirclePoints[6]}] &, hex
Translate[hex, 
 Join @@ {Table[{42 kj Cos[Pi/3]+ i, 0i Sqrt[3]}, {k, 1i, w }]0, Table[2 kh {Cos[Pi/3],- Sin[Pi/3]1}, {kj, 10, hw }]- 1}]]]]]

Examples:

Graphics[triHex[10, 5], ImageSize -> 600]

enter image description hereenter image description here

Graphics[triHex[7, 7] /. White -> LightBlue, ImageSize -> 600]

enter image description hereenter image description here

ClearAll[triHex];
triHex[w_, h_] := Module[{hex = {FaceForm[White], EdgeForm[Black], Polygon@#, 
   Red, PointSize[Large], Point@#} &@ Table[{Cos[2 Pi k /6], Sin[2 Pi k /6]}, {k, 6}]}, 
 Fold[Translate[#, {{0, 0}, ## & @@ #2}] &, hex, 
   {Table[{4 k Cos[Pi/3], 0}, {k, 1, w }], Table[2 k {Cos[Pi/3], Sin[Pi/3]}, {k, 1, h }]}]]

Examples:

Graphics[triHex[10, 5], ImageSize -> 600]

enter image description here

Graphics[triHex[7, 7] /. White -> LightBlue, ImageSize -> 600]

enter image description here

ClearAll[triHex];
triHex[w_, h_] := Module[{hex = {FaceForm[White], EdgeForm[Black], PointSize[Large],  
 Polygon @ #, Red, Point @ #} & @ CirclePoints[6]}, 
Translate[hex, Join @@ Table[{2 j + i, i Sqrt[3]}, {i, 0, h - 1}, {j, 0, w - 1}]]]

Examples:

Graphics[triHex[10, 5], ImageSize -> 600]

enter image description here

Graphics[triHex[7, 7] /. White -> LightBlue, ImageSize -> 600]

enter image description here

deleted 16 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

###Translate

ClearAll[triHex];
triHex[w_, h_] := Module[{hex = {FaceForm[White], EdgeForm[Black], Polygon@#, 
   Red, PointSize[Large], Point@#} &@ Table[{Cos[2 Pi k /6], Sin[2 Pi k /6]}, {k, 6}]}, 
 Fold[Translate[#, {{0, 0}, ## & @@ #2}] &, hex, 
  {Table[{4 k Cos[Pi/3], 0}, {k, 1, w }], Table[2 k {Cos[Pi/3], Sin[Pi/3]}, {k, 1, h }]}]]

Examples:

Graphics[triHex[10, 5], ImageSize -> 600]

enter image description here

Graphics[triHex[7, 7] /. White -> LightBlue, ImageSize -> 600]

enter image description here

###Translate

ClearAll[triHex];
triHex[w_, h_] := Module[{hex = {FaceForm[White], EdgeForm[Black], Polygon@#, 
   Red, PointSize[Large], Point@#} &@ Table[{Cos[2 Pi k /6], Sin[2 Pi k /6]}, {k, 6}]}, 
 Fold[Translate[#, {{0, 0}, ## & @@ #2}] &, hex, 
  {Table[{4 k Cos[Pi/3], 0}, {k, 1, w }], Table[2 k {Cos[Pi/3], Sin[Pi/3]}, {k, 1, h }]}]]

Examples:

Graphics[triHex[10, 5], ImageSize -> 600]

enter image description here

Graphics[triHex[7, 7] /. White -> LightBlue, ImageSize -> 600]

enter image description here

ClearAll[triHex];
triHex[w_, h_] := Module[{hex = {FaceForm[White], EdgeForm[Black], Polygon@#, 
   Red, PointSize[Large], Point@#} &@ Table[{Cos[2 Pi k /6], Sin[2 Pi k /6]}, {k, 6}]}, 
 Fold[Translate[#, {{0, 0}, ## & @@ #2}] &, hex, 
  {Table[{4 k Cos[Pi/3], 0}, {k, 1, w }], Table[2 k {Cos[Pi/3], Sin[Pi/3]}, {k, 1, h }]}]]

Examples:

Graphics[triHex[10, 5], ImageSize -> 600]

enter image description here

Graphics[triHex[7, 7] /. White -> LightBlue, ImageSize -> 600]

enter image description here

Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

###Translate

ClearAll[triHex];
triHex[w_, h_] := Module[{hex = {FaceForm[White], EdgeForm[Black], Polygon@#, 
   Red, PointSize[Large], Point@#} &@ Table[{Cos[2 Pi k /6], Sin[2 Pi k /6]}, {k, 6}]}, 
 Fold[Translate[#, {{0, 0}, ## & @@ #2}] &, hex, 
  {Table[{4 k Cos[Pi/3], 0}, {k, 1, w }], Table[2 k {Cos[Pi/3], Sin[Pi/3]}, {k, 1, h }]}]]

Examples:

Graphics[triHex[10, 5], ImageSize -> 600]

enter image description here

Graphics[triHex[7, 7] /. White -> LightBlue, ImageSize -> 600]

enter image description here