Function Repository Resource:

HatHexagonalTiling

Source Notebook

Generate the hexagonal tiling pattern of the hat and its supertiles

Contributed by: Bowen Ping

ResourceFunction["HatHexagonalTiling"][init]

plots the hat tiling initial conditions for integer init from 1 to 10.

ResourceFunction["HatHexagonalTiling"][init,size]

plots the hat tiling with init as initial conditions for a hexagonal array of integer size layers.

ResourceFunction["HatHexagonalTiling"][init,size,"type"]

plots the combinatorial tiling of the given type.

ResourceFunction["HatHexagonalTiling"][init,size,typelist]

plots the combinatorial tilings of all types in the typelist.

Details

ResourceFunction["HatHexagonalTiling"] generates a tiling based on the einstein hat tile of Smith et al., similar to the resource function HatHexagons. However, the two functions generate tilings through different methods.
ResourceFunction["HatHexagonalTiling"] uses combinatorial hexagons to generate tilings through the built-in function SatisfiabilityInstances.
Supported tiling types include the following:
"Hexagon"combinatorial hexagons
"Hat"the Hat tiles
"Cluster"1-level supertiles of the Hat
"SuperCluster"2-level supertiles of the Hat
"n-Supertile"n-level supertiles of the Hat
ResourceFunction["HatHexagonalTiling"] has the same options as Graphics, with the following additions:
ColorFunctionAutomaticfunction with inputs from 1 to 10, gives colors as output.
ColorRulesAutomaticlist of rules from integers (from 1 to 10) to colors.
"Count"1required number of possible tilings.
The setting "Count"All generates all possible tilings.

Examples

Basic Examples (3) 

Plot a single hat tile:

In[1]:=
ResourceFunction["HatHexagonalTiling"][1, ImageSize -> 150]
Out[1]=

Plot a hexagonal tiling of three layers of the Hat tiles:

In[2]:=
ResourceFunction["HatHexagonalTiling"][1, 3, ImageSize -> 300]
Out[2]=

Plot with combinatorial hexagon, the Hat, its supertile (cluster), 2-supertile and so on:

In[3]:=
ResourceFunction["HatHexagonalTiling"][4, 1, {"Hexagon", "Hat", "Cluster", "2-Supertile", "3-Supertile", "4-Supertile"}] // Partition[#, UpTo[3]] & // Grid
Out[3]=

Scope (4) 

Generate three different combinatorial equivalent tilings with two types of tiles:

In[4]:=
Grid[Insert[
  ResourceFunction["HatHexagonalTiling"][6, 1, {"Hat", "1-Supertile"},
    "Count" -> 3],
  ConstantArray[Style["\[DoubleUpDownArrow]", 40, Gray], 3], 2], Spacings -> {1, 1}, Frame -> {All, True}, FrameStyle -> Lighter@Red]
Out[4]=

There are 10 different initial conditions:

In[5]:=
Grid[Partition[
  ResourceFunction["HatHexagonalTiling"][#, ImageSize -> 100] & /@ Range[10], 5]]
Out[5]=

Compare with its supertiles:

In[6]:=
Grid[Partition[
  Flatten@Outer[
    ResourceFunction["HatHexagonalTiling"][#2, #1, ImageSize -> 100] &, {"Cluster", "SuperCluster"}, Range[10]], 5]
 , Dividers -> {{1 -> True, -1 -> True}, {1 -> True, 3 -> True, -1 -> True}}, FrameStyle -> LightGray]
Out[6]=

You can generate any higher level supertiles as you want:

In[7]:=
Grid[Partition[
  Flatten@Outer[
    ResourceFunction["HatHexagonalTiling"][#2, #1, ImageSize -> 100] &, {"3-Supertile", "4-Supertile"}, {7, 10}], 2]
 , Dividers -> {{1 -> True, -1 -> True}, {1 -> True, 2 -> True, -1 -> True}}, FrameStyle -> LightGray]
Out[7]=

Options (5) 

ColorFunction (1) 

Add red EdgeForm in a blue tiling:

In[8]:=
ResourceFunction["HatHexagonalTiling"][1, 2, "Hat", ColorFunction -> Function[{EdgeForm[Red], Lighter[Blue, (12 - #)/12]}], ImageSize -> 300]
Out[8]=

ColorRules (2) 

Color the tiling using GrayLevel:

In[9]:=
ResourceFunction["HatHexagonalTiling"][1, 2, "Hat", ColorRules -> (x_ :> GrayLevel[x/12]), ImageSize -> 300]
Out[9]=

Add red EdgeForm in a blue tiling:

In[10]:=
ResourceFunction["HatHexagonalTiling"][1, 2, "Hat", ColorRules -> (x_ :> {EdgeForm[Red], Lighter[Blue, (12 - x)/12]}), ImageSize -> 300]
Out[10]=

Count (2) 

Use "Count" to generate more possible tilings:

In[11]:=
ResourceFunction["HatHexagonalTiling"][10, 2, "Count" -> 3]
Out[11]=

Generate all valid one layer surroundings:

In[12]:=
Grid[Partition[
  ResourceFunction["HatHexagonalTiling"][1, 1, "Count" -> All, ImageSize -> 150], UpTo[4]]]
Out[12]=

Properties and Relations (4) 

HatHexagons (2) 

The resource function HatHexagons generates tilings by substitution rule, which gives a fractal structure. HatHexagonalTiling focuses on surrounding the center tile by multiple layers. Compare the results of two functions after using the same initial conditions:

In[13]:=
Outer[
  Labeled[
    Row[{Show[ResourceFunction["HatHexagons"][#1, #2], ImageSize -> 100], ResourceFunction["HatHexagonalTiling"][#1, #2, "Hexagon", ImageSize -> 100]}]
    , Style["init:" <> ToString[#1] <> " level:" <> ToString[#2], 12]] &
  , Range[2], Range[0, 2]
  ] // Grid[#, Frame -> {False, All}, FrameStyle -> LightGray] &
Out[13]=

You can use this function to generate higher level supertiles of the Hat as a whole, and use HatHexagons to see how it is made of the hat tiles:

In[14]:=
MapThread[
   {ResourceFunction["HatHexagonalTiling"][6, 0, #1, ImageSize -> 150],
     ResourceFunction["HatHexagons"][6, #2, "Hat", ImageSize -> 150]} &,
   {{"1-Supertile", "2-Supertile", "3-Supertile"}, {1, 2, 3}}
   ] // Transpose // Grid[#, Dividers -> {All, True}, FrameStyle -> LightGray] &
Out[14]=

Supertiles (1) 

The "Cluster" is exactly 1-Supertile, the "SuperCluster" is exactly 2-Supertile and the "Hat" is the "0-Supertile":

In[15]:=
Labeled[Row[ResourceFunction["HatHexagonalTiling"][9, 0, #]], #[[1]] <>
      "  " <> #[[2]]] & /@ {
   {"Hat", "0-Supertile"},
   {"Cluster", "1-Supertile"},
   {"SuperCluster", "2-Supertile"}
   } // Column[#, Frame -> All, FrameStyle -> Gray, Alignment -> Center] &
Out[15]=

Reflected Tiles (1) 

The holes in the Hat tiling are where the reflected tiles should be. An easy way to fill them is:

In[16]:=
Replace[ResourceFunction["HatHexagonalTiling"][1, 6, "Hat", ImageSize -> 400]
 , {a___, Lighter[Hue[10/11], .6], p_Polygon, b___} :> {
   a, Lighter[Hue[10/11], 0.6], p,
   Lighter[Hue[1], 0.4], Polygon[{{
Rational[-3, 2], Rational[1, 2] 3^Rational[1, 2]}, {
Rational[-3, 2], Rational[3, 2] 3^Rational[1, 2]}, {
Rational[-1, 2], Rational[3, 2] 3^Rational[1, 2]}, {
Rational[1, 2], Rational[5, 2] 3^Rational[1, 2]}, {0, 3 3^Rational[1, 2]}, {
Rational[-3, 2], Rational[5, 2] 3^Rational[1, 2]}, {-3, 3 3^Rational[1, 2]}, {
Rational[-7, 2], Rational[5, 2] 3^Rational[1, 2]}, {
Rational[-9, 2], Rational[5, 2] 3^Rational[1, 2]}, {
Rational[-9, 2], Rational[3, 2] 3^Rational[1, 2]}, {-3, 3^Rational[1, 2]}, {
Rational[-7, 2], Rational[1, 2] 3^Rational[1, 2]}, {-3, 0}} . Transpose[
       RotationMatrix[(ArcTan @@ (p[[1, 2]] - p[[1, 1]])) + Pi/6]] + Threaded[p[[1, 1]]]], b}
 , {2}]
Out[16]=

Possible Issues (3) 

Duplicate elements in typelist will give duplicate corresponding results:

In[17]:=
ResourceFunction["HatHexagonalTiling"][8, 1, {"Hat", "Hat"}]
Out[17]=

If you want to generate combinatorial tilings with different type of tiles, please use the typelist argument rather than Map. There is a significant efficiency difference:

In[18]:=
tilings1 = ResourceFunction["HatHexagonalTiling"][8, 5, {"Hat", "Cluster", "SuperCluster"}, "Count" -> 3]; // RepeatedTiming
Out[18]=
In[19]:=
tilings2 = ResourceFunction["HatHexagonalTiling"][8, 5, #, "Count" -> 3] & /@ {"Hat", "Cluster", "SuperCluster"}; // RepeatedTiming
Out[19]=

They have the same result:

In[20]:=
tilings1 === tilings2
Out[20]=

Neat Examples (1) 

Show the two kinds of tiles next to the reflected tiles:

In[21]:=
ResourceFunction["HatHexagonalTiling"][1, 15, "Hat", ColorRules -> {4 -> Green, 10 -> Red, _ -> LightBlue}, ImageSize -> 600]
Out[21]=

Publisher

Bowen Ping

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.1.2 – 08 May 2024
  • 1.1.1 – 06 December 2023
  • 1.1.0 – 04 December 2023
  • 1.0.0 – 15 November 2023

Source Metadata

Related Resources

License Information