From 944416f92bf63d903d702dfda6814b1c7aa460dd Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Fri, 27 Oct 2023 10:42:35 +1100 Subject: [PATCH] Visualisations of combinations of layers --- gui.js | 3 ++- main.js | 6 ++++++ polytopes.js | 32 ++++++++++++++++++++++++++++---- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/gui.js b/gui.js index cf202d5..68e625b 100644 --- a/gui.js +++ b/gui.js @@ -46,7 +46,8 @@ class FourDGUI { this.gui.add(this.params, 'shape', [ 'dodecahedron', '5-cell', '16-cell', 'tesseract', - '24-cell', '600-cell', '120-cell' ] + '24-cell', '600-cell', '120-cell', + '120-cell-a', '120-cell-b', '120-cell-c', '120-cell-d', '120-cell-e', '120-cell-f' ] ).onChange(changeShape) this.gui.add(this.params, 'inscribed').onChange(changeShape); this.gui.add(this.params, 'inscribe_all').onChange(changeShape); diff --git a/main.js b/main.js index e05f43a..b0e2ed7 100644 --- a/main.js +++ b/main.js @@ -69,6 +69,12 @@ const STRUCTURES = { '24-cell': POLYTOPES.cell24(), 'dodecahedron': POLYTOPES.dodecahedron(), '120-cell': POLYTOPES.cell120(), + '120-cell-a': POLYTOPES.cell120_layered(1), + '120-cell-b': POLYTOPES.cell120_layered(2), + '120-cell-c': POLYTOPES.cell120_layered(3), + '120-cell-d': POLYTOPES.cell120_layered(4), + '120-cell-e': POLYTOPES.cell120_layered(5), + '120-cell-f': POLYTOPES.cell120_layered(6), '600-cell': POLYTOPES.cell600(), }; diff --git a/polytopes.js b/polytopes.js index 15526e9..f57a553 100644 --- a/polytopes.js +++ b/polytopes.js @@ -332,6 +332,8 @@ function make_120cell_vertices() { + + function label_nodes(nodes, ids, label) { nodes.filter((n) => ids.includes(n.id)).map((n) => n.label = label); } @@ -379,10 +381,12 @@ function label_120cell(nodes) { } -function layered_120cell(nodes) { + + +function layered_120cell(nodes, max_layer) { for (const cstr in CELL120.LAYERS ) { - label_nodes(nodes, CELL120.LAYERS[cstr], Number(cstr)); + label_nodes(nodes, CELL120.LAYERS[cstr], Number(cstr)); } } @@ -400,8 +404,7 @@ export const cell120 = () => { const nodes = make_120cell_vertices(); const links = auto_detect_edges(nodes, 4); - //label_120cell(nodes); - layered_120cell(nodes); + label_120cell(nodes); return { nodes: nodes, @@ -413,6 +416,27 @@ export const cell120 = () => { } } +export const cell120_layered = (max) => { + const nodes = make_120cell_vertices(); + const links = auto_detect_edges(nodes, 4); + + layered_120cell(nodes); + + const layer_nodes = nodes.filter((n) => n.label < max); + const layer_links = links.filter((l) => { + const labels = link_labels(nodes, l); + return labels[0] < max && labels[1] < max + }); + + return { + nodes: layer_nodes, + links: layer_links, + geometry: { + node_size: 0.02, + link_size: 0.02 + }, + } +}