Generative Reflection (GR) kernel
In this notebook we provide examples of how tilings made with the generative reflection (GR) kernel can be used
[9]:
from hypertiling import HyperbolicTiling
from hypertiling.graphics.plot import plot_tiling
import matplotlib.cm as cmap
import numpy as np
import time
Example 1: The hypertiling logo
[2]:
t1 = time.time()
t = HyperbolicTiling(7, 3, 3, kernel="GR")
print(f"Generation of {len(t): d} polygons took {time.time() - t1} s")
Generation of 29 polygons took 0.0010960102081298828 s
[3]:
ct = np.zeros(len(t))
for i, poly in enumerate(t):
val = np.real(poly[0])-np.imag(poly[0])
ct[i] = np.sign(val)*(np.abs(val))**1.4
[4]:
plot_tiling(t, ct, cmap=cmap.RdYlGn, edgecolor="w", lw=5, clim=[-1,1]);

Example 2: Save as vector graphics
[5]:
from hypertiling import HyperbolicTiling
import hypertiling.graphics.svg as svg
import numpy as np
[6]:
tiling = HyperbolicTiling(5,4,6, kernel="GR")
colors = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
# query layer information
tiling_colors = [colors[tiling.get_layer(i) % len(colors)] for i in range(len(tiling))]
# create and draw svg image
tiling_svg = svg.make_svg(tiling, tiling_colors, unitcircle=True, cmap="RdBu_r")
svg.draw_svg(tiling_svg)
Layers are not yet mapped. Start mapping
Example 3: Voter model
In this simple statistic model, cells will always take on the color of the majority of their adjacent cells
[10]:
from hypertiling.graphics.plot import plot_tiling
import random
import matplotlib.pyplot as plt
import matplotlib.cm as cmap
[11]:
t1 = time.time()
p, q, n = 7, 3, 11
t = HyperbolicTiling(p, q, n, kernel="GR")
print(f"Generation of {len(t): d} polygons took {time.time() - t1} s")
Generation of 76616 polygons took 0.07186460494995117 s
Extract the neighbours
[16]:
nbrs = t.get_nbrs_list()
The actual voter model
[17]:
# initial state
states = np.random.randint(0, 2, size=len(t))
plot_tiling(t, states, cmap=cmap.Greys, edgecolor="k", cutoff=0.01, lw=0.7, clim=[0,2]);

[18]:
# final state
its = 2 * len(t) # 2 times is a bit lazy but it is just an example
p_2 = p // 2
for i in range(its):
index = int(len(t) * np.random.random())
sum_ = sum([states[nbr] for nbr in t.get_nbrs_mapping(index)])
# sum_ = sum([states[nbr] for nbr in nbrs[index]]) # faster neighbor access but more memory requiered
if sum_ > p_2:
states[index] = 1
else:
states[index] = 0
plot_tiling(t, states, cmap=cmap.Greys, edgecolor="k", cutoff=0.01, lw=0.7, clim=[0,2]);

[ ]: