Browse all master set geometries and their CPS structures using the dropdowns below.
A MasterSet is a generating geometry for a Combination Product Set. The shape determines the structure of the resultant CPS. Different values of r yield different CPS from the same master set.
Live interaction required. Press the power button at the top of this page to activate a live kernel. Widget controls will not respond until a kernel is connected.
from klotho import plot
from klotho.tonos import CombinationProductSet, MasterSet
from klotho.tonos.systems.combination_product_sets.master_set import MASTER_SETS
import ipywidgets as widgets
from IPython.display import display, clear_output
PRIMES = (1, 3, 5, 7, 9, 11, 13, 17, 19, 23)2D Master Sets¶
CPS_PRESETS_2D = {
'kite': (2,),
'arrow': (2,),
'k23_bipartite': (2,),
'house': (2,),
'wheel4': (2,),
'wheel5': (2, 3),
'nested_triangles': (2, 3),
'heptagon': (2, 3),
}
ms_2d = {}
for name, factory in MASTER_SETS.items():
ms = factory()
if ms.dimensionality == 2:
ms_2d[name] = len(ms.positions)
if name not in CPS_PRESETS_2D:
CPS_PRESETS_2D[name] = (2,)
ms_names_2d = sorted(ms_2d.keys(), key=lambda k: (ms_2d[k], k))
ms_labels_2d = {name: f"{name} ({ms_2d[name]} nodes)" for name in ms_names_2d}
DEFAULT_MS_2D = 'kite'Geometry Viewer¶
Select a 2D master set to view its generating geometry.
geom_dropdown_2d = widgets.Dropdown(
options=[(ms_labels_2d[n], n) for n in ms_names_2d],
value=DEFAULT_MS_2D,
description='Master Set:',
style={'description_width': '90px'},
layout=widgets.Layout(width='300px'),
)
geom_out_2d = widgets.Output()
def show_geometry_2d(_=None):
with geom_out_2d:
clear_output(wait=True)
name = geom_dropdown_2d.value
ms = MASTER_SETS[name]()
n = len(ms.positions)
e = len(ms.edges)
print(f'Generating Geometry: {name} ({n} nodes, {e} edges)')
plot(ms, figsize=(4, 4))
geom_dropdown_2d.observe(show_geometry_2d, names='value')
display(widgets.VBox([geom_dropdown_2d, geom_out_2d]))
show_geometry_2d()CPS Viewer¶
Select a 2D master set and r value to view the resulting CPS. Only r values that produce structurally interesting CPS are shown for each master set.
cps_ms_dropdown_2d = widgets.Dropdown(
options=[(ms_labels_2d[n], n) for n in ms_names_2d],
value=DEFAULT_MS_2D,
description='Master Set:',
style={'description_width': '90px'},
layout=widgets.Layout(width='300px'),
)
cps_r_dropdown_2d = widgets.Dropdown(
options=[2],
value=2,
description='r:',
style={'description_width': '30px'},
layout=widgets.Layout(width='120px'),
)
cps_out_2d = widgets.Output()
def update_r_options_2d(_=None):
name = cps_ms_dropdown_2d.value
r_vals = list(CPS_PRESETS_2D.get(name, (2,)))
cps_r_dropdown_2d.options = r_vals
cps_r_dropdown_2d.value = r_vals[0]
def show_cps_2d(_=None):
with cps_out_2d:
clear_output(wait=True)
name = cps_ms_dropdown_2d.value
n_nodes = ms_2d[name]
r = cps_r_dropdown_2d.value
factors = PRIMES[:n_nodes]
cps = CombinationProductSet(factors, r=r, master_set=name)
n_notes = len(cps.ratios)
print(f'{name} CPS r={r} ({n_notes} notes)')
print(f'Factors: {factors}')
print(f'Ratios: {" ".join(str(x) for x in cps.ratios)}')
ns = max(10, 30 - n_notes)
ts = max(6, 12 - n_notes // 5)
plot(cps, node_size=ns, text_size=ts, figsize=(8, 8))
cps_ms_dropdown_2d.observe(update_r_options_2d, names='value')
cps_ms_dropdown_2d.observe(show_cps_2d, names='value')
cps_r_dropdown_2d.observe(show_cps_2d, names='value')
display(widgets.VBox([widgets.HBox([cps_ms_dropdown_2d, cps_r_dropdown_2d]), cps_out_2d]))
update_r_options_2d()
show_cps_2d()3D Master Sets¶
CPS_PRESETS_3D = {
'octahedron': (2, 3),
'trigonal_bipyramid': (2,),
'triangular_prism': (2, 3),
'pentagonal_bipyramid': (2, 3),
'kite_pyramid': (2,),
}
ms_3d = {}
for name, factory in MASTER_SETS.items():
ms = factory()
if ms.dimensionality == 3:
ms_3d[name] = len(ms.positions)
if name not in CPS_PRESETS_3D:
CPS_PRESETS_3D[name] = (2,)
ms_names_3d = sorted(ms_3d.keys(), key=lambda k: (ms_3d[k], k))
ms_labels_3d = {name: f"{name} ({ms_3d[name]} nodes)" for name in ms_names_3d}
DEFAULT_MS_3D = 'octahedron'Geometry Viewer¶
Select a 3D master set to view its generating geometry. Use the transport bar below the plot to adjust node size and toggle between Orbit and Trackball rotation.
geom_dropdown_3d = widgets.Dropdown(
options=[(ms_labels_3d[n], n) for n in ms_names_3d],
value=DEFAULT_MS_3D,
description='Master Set:',
style={'description_width': '90px'},
layout=widgets.Layout(width='350px'),
)
geom_out_3d = widgets.Output()
def show_geometry_3d(_=None):
with geom_out_3d:
clear_output(wait=True)
name = geom_dropdown_3d.value
ms = MASTER_SETS[name]()
n = len(ms.positions)
e = len(ms.edges)
print(f'Generating Geometry: {name} ({n} nodes, {e} edges)')
plot(ms, figsize=(4, 4))
geom_dropdown_3d.observe(show_geometry_3d, names='value')
display(widgets.VBox([geom_dropdown_3d, geom_out_3d]))
show_geometry_3d()CPS Viewer¶
Select a 3D master set and r value to view the resulting CPS. Only r values that produce structurally interesting CPS are shown for each master set.
cps_ms_dropdown_3d = widgets.Dropdown(
options=[(ms_labels_3d[n], n) for n in ms_names_3d],
value=DEFAULT_MS_3D,
description='Master Set:',
style={'description_width': '90px'},
layout=widgets.Layout(width='350px'),
)
cps_r_dropdown_3d = widgets.Dropdown(
options=[2, 3],
value=2,
description='r:',
style={'description_width': '30px'},
layout=widgets.Layout(width='120px'),
)
cps_out_3d = widgets.Output()
def update_r_options_3d(_=None):
name = cps_ms_dropdown_3d.value
r_vals = list(CPS_PRESETS_3D.get(name, (2,)))
cps_r_dropdown_3d.options = r_vals
cps_r_dropdown_3d.value = r_vals[0]
def show_cps_3d(_=None):
with cps_out_3d:
clear_output(wait=True)
name = cps_ms_dropdown_3d.value
n_nodes = ms_3d[name]
r = cps_r_dropdown_3d.value
factors = PRIMES[:n_nodes]
cps = CombinationProductSet(factors, r=r, master_set=name)
n_notes = len(cps.ratios)
print(f'{name} CPS r={r} ({n_notes} notes)')
print(f'Factors: {factors}')
print(f'Ratios: {" ".join(str(x) for x in cps.ratios)}')
plot(cps, node_size=2, text_size=8, figsize=(8, 8))
cps_ms_dropdown_3d.observe(update_r_options_3d, names='value')
cps_ms_dropdown_3d.observe(show_cps_3d, names='value')
cps_r_dropdown_3d.observe(show_cps_3d, names='value')
display(widgets.VBox([widgets.HBox([cps_ms_dropdown_3d, cps_r_dropdown_3d]), cps_out_3d]))
update_r_options_3d()
show_cps_3d()