From fb8067a13e03cf41d1c4e0b5f663fb7d512fbf85 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Thu, 14 Sep 2023 16:42:20 +1000 Subject: [PATCH 1/3] added a dodecahedron --- gui.js | 2 +- main.js | 1 + polytopes.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ testbed.js | 40 +++++++++++++++++++++++++++++----------- 4 files changed, 82 insertions(+), 12 deletions(-) diff --git a/gui.js b/gui.js index 921a98f..064c6d7 100644 --- a/gui.js +++ b/gui.js @@ -46,7 +46,7 @@ class FourDGUI { this.gui.add(this.params, 'shape', [ '5-cell', '16-cell', 'tesseract', - '24-cell', '600-cell', '120-cell' ] + '24-cell', '600-cell', '120-cell', 'dodecahedron' ] ).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 3282f19..e04b485 100644 --- a/main.js +++ b/main.js @@ -64,6 +64,7 @@ const STRUCTURES = { '16-cell': POLYTOPES.cell16(), 'tesseract': POLYTOPES.tesseract(), '24-cell': POLYTOPES.cell24(), + 'dodecahedron': POLYTOPES.dodecahedron(), '120-cell': POLYTOPES.cell120(), '600-cell': POLYTOPES.cell600(), }; diff --git a/polytopes.js b/polytopes.js index 39736f0..3b35b85 100644 --- a/polytopes.js +++ b/polytopes.js @@ -668,3 +668,54 @@ const cell600_some_inscribed = (ps) => { export const cell600_inscribed = () => cell600_some_inscribed([1]); export const cell600_all_inscribed = () => cell600_some_inscribed([1,2,3,4,5]); + + +function make_dodecahedron_vertices() { + const phi = 0.5 * (1 + Math.sqrt(5)); + const phiinv = 1 / phi; + + const nodes = [ + { x: 1, y: 1, z: 1, w: 0 }, + { x: 1, y: 1, z: -1, w: 0 }, + { x: 1, y: -1, z: 1, w: 0 }, + { x: 1, y: -1, z: -1, w: 0 }, + + { x: -1, y: 1, z: 1, w: 0 }, + { x: -1, y: 1, z: -1, w: 0 }, + { x: -1, y: -1, z: 1, w: 0 }, + { x: -1, y: -1, z: -1, w: 0 }, + + { x: 0, y: phi, z: phiinv, w: 0 }, + { x: 0, y: phi, z: -phiinv, w: 0 }, + { x: 0, y: -phi, z: phiinv, w: 0 }, + { x: 0, y: -phi, z: -phiinv, w: 0 }, + + { x: phiinv, y: 0, z: phi, w: 0 }, + { x: phiinv, y: 0, z: -phi, w: 0 }, + { x: -phiinv, y: 0, z: phi, w: 0 }, + { x: -phiinv, y: 0, z: -phi, w: 0 }, + + { x: phi, y: phiinv, z:0, w: 0 }, + { x: phi, y: -phiinv, z:0, w: 0 }, + { x: -phi, y: phiinv, z:0, w: 0 }, + { x: -phi, y: -phiinv, z:0, w: 0 }, + ]; + index_nodes(nodes);; + return nodes; +} + +export const dodecahedron = () => { + const nodes = make_dodecahedron_vertices(); + const links = auto_detect_edges(nodes, 3); + + return { + nodes: nodes, + links: links, + geometry: { + node_size: 0.02, + link_size: 0.02 + } + } +} + + diff --git a/testbed.js b/testbed.js index c0633ab..7064d83 100644 --- a/testbed.js +++ b/testbed.js @@ -907,25 +907,43 @@ function check_120cell_nodes(nodes) { } }); } + +function make_dodecahedron_vertices() { + const phi = 0.5 * (1 + Math.sqrt(5)); + const phiinv = 1 / phi; + + const nodes = [ + { x: 1, y: 1, z: 1, w: 0 }, + { x: 1, y: 1, z: -1, w: 0 }, + { x: 1, y: -1, z: 1, w: 0 }, + { x: 1, y: -1, z: -1, w: 0 }, + { x: -1, y: 1, z: 1, w: 0 }, + { x: -1, y: 1, z: -1, w: 0 }, + { x: -1, y: -1, z: 1, w: 0 }, + { x: -1, y: -1, z: -1, w: 0 } + ].flat(); + scale_nodes(nodes, 0.5); + return nodes; +} -const nodes = make_120cell_vertices(); -const links = auto_detect_edges(nodes, 4); -const faces = auto_120cell_faces(links); +// const nodes = make_120cell_vertices(); +// const links = auto_detect_edges(nodes, 4); +// const faces = auto_120cell_faces(links); -console.log("Calculating 120-cell colours") +// console.log("Calculating 120-cell colours") -const a2 = arctic_two(nodes, links, faces, faces[0], 341) +// const a2 = arctic_two(nodes, links, faces, faces[0], 341) -console.log(`got ${a2.dodecahedra.length}`); +// console.log(`got ${a2.dodecahedra.length}`); -const labels = a2.labels; +// const labels = a2.labels; -console.log("labelling nodes"); -for( const cstr in labels ) { - label_nodes(nodes, labels[cstr], Number(cstr)); -} +// console.log("labelling nodes"); +// for( const cstr in labels ) { +// label_nodes(nodes, labels[cstr], Number(cstr)); +// } -- 2.48.1 From 6e8cfa8763f3468f5c5e705b5bcec0cb8a5584d7 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Fri, 15 Sep 2023 18:33:33 +1000 Subject: [PATCH 2/3] Added tetrahedra inscriptions for dodecahedron, rearranged UI --- gui.js | 4 +-- main.js | 2 ++ polytopes.js | 78 +++++++++++++++++++++++++++++++--------------------- 3 files changed, 51 insertions(+), 33 deletions(-) diff --git a/gui.js b/gui.js index 064c6d7..cf202d5 100644 --- a/gui.js +++ b/gui.js @@ -45,8 +45,8 @@ class FourDGUI { }; this.gui.add(this.params, 'shape', - [ '5-cell', '16-cell', 'tesseract', - '24-cell', '600-cell', '120-cell', 'dodecahedron' ] + [ 'dodecahedron', '5-cell', '16-cell', 'tesseract', + '24-cell', '600-cell', '120-cell' ] ).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 e04b485..ab2abd5 100644 --- a/main.js +++ b/main.js @@ -74,6 +74,7 @@ const INSCRIBED = { '24-cell': POLYTOPES.cell24_inscribed(), '120-cell': POLYTOPES.cell120_inscribed(), '600-cell': POLYTOPES.cell600_inscribed(), + 'dodecahedron': POLYTOPES.dodecahedron_inscribed(), }; const ALL_INSCRIBED = { @@ -81,6 +82,7 @@ const ALL_INSCRIBED = { '24-cell': POLYTOPES.cell24_all_inscribed(), '120-cell': POLYTOPES.cell120_all_inscribed(), '600-cell': POLYTOPES.cell600_all_inscribed(), + 'dodecahedron': POLYTOPES.dodecahedron_all_inscribed(), } let shape = false; diff --git a/polytopes.js b/polytopes.js index 3b35b85..6d80f0a 100644 --- a/polytopes.js +++ b/polytopes.js @@ -652,16 +652,6 @@ const cell600_some_inscribed = (ps) => { link_size: 0.02 }, } - - - return { - nodes: nodes, - links: links, - geometry: { - node_size: 0.02, - link_size: 0.02 - } - } } @@ -675,32 +665,32 @@ function make_dodecahedron_vertices() { const phiinv = 1 / phi; const nodes = [ - { x: 1, y: 1, z: 1, w: 0 }, - { x: 1, y: 1, z: -1, w: 0 }, - { x: 1, y: -1, z: 1, w: 0 }, - { x: 1, y: -1, z: -1, w: 0 }, + { x: 1, y: 1, z: 1, w: 0, label: 4 }, + { x: 1, y: 1, z: -1, w: 0, label: 3 }, + { x: 1, y: -1, z: 1, w: 0, label: 3 }, + { x: 1, y: -1, z: -1, w: 0, label: 2 }, - { x: -1, y: 1, z: 1, w: 0 }, - { x: -1, y: 1, z: -1, w: 0 }, - { x: -1, y: -1, z: 1, w: 0 }, - { x: -1, y: -1, z: -1, w: 0 }, + { x: -1, y: 1, z: 1, w: 0, label: 3 }, + { x: -1, y: 1, z: -1, w: 0, label: 1 }, + { x: -1, y: -1, z: 1, w: 0, label: 5 }, + { x: -1, y: -1, z: -1, w: 0, label: 3 }, - { x: 0, y: phi, z: phiinv, w: 0 }, - { x: 0, y: phi, z: -phiinv, w: 0 }, - { x: 0, y: -phi, z: phiinv, w: 0 }, - { x: 0, y: -phi, z: -phiinv, w: 0 }, + { x: 0, y: phi, z: phiinv, w: 0, label: 5 }, + { x: 0, y: phi, z: -phiinv, w: 0 , label: 2 }, + { x: 0, y: -phi, z: phiinv, w: 0, label: 4 }, + { x: 0, y: -phi, z: -phiinv, w: 0 , label: 1 }, - { x: phiinv, y: 0, z: phi, w: 0 }, - { x: phiinv, y: 0, z: -phi, w: 0 }, - { x: -phiinv, y: 0, z: phi, w: 0 }, - { x: -phiinv, y: 0, z: -phi, w: 0 }, + { x: phiinv, y: 0, z: phi, w: 0 , label: 2}, + { x: phiinv, y: 0, z: -phi, w: 0 , label: 4}, + { x: -phiinv, y: 0, z: phi, w: 0 , label: 1}, + { x: -phiinv, y: 0, z: -phi, w: 0 , label: 5}, - { x: phi, y: phiinv, z:0, w: 0 }, - { x: phi, y: -phiinv, z:0, w: 0 }, - { x: -phi, y: phiinv, z:0, w: 0 }, - { x: -phi, y: -phiinv, z:0, w: 0 }, + { x: phi, y: phiinv, z:0, w: 0 , label: 1}, + { x: phi, y: -phiinv, z:0, w: 0 , label: 5}, + { x: -phi, y: phiinv, z:0, w: 0 , label: 4}, + { x: -phi, y: -phiinv, z:0, w: 0 , label: 2}, ]; - index_nodes(nodes);; + index_nodes(nodes); return nodes; } @@ -718,4 +708,30 @@ export const dodecahedron = () => { } } +const dodecahedron_some_inscribed = (ps) => { + const nodes = make_dodecahedron_vertices(); + const links = auto_detect_edges(nodes, 3); + const all_links = links; + all_links.map((l) => l.label = 0); + + for( const p of ps) { + const tetran = nodes.filter((n) => n.label === p); + const tetral = auto_detect_edges(tetran, 3); + tetral.map((l) => l.label = p); + all_links.push(...tetral); + } + + return { + nodes: nodes, + links: all_links, + geometry: { + node_size: 0.02, + link_size: 0.02 + }, + } +} + + +export const dodecahedron_inscribed = () => dodecahedron_some_inscribed([1]); +export const dodecahedron_all_inscribed = () => dodecahedron_some_inscribed([1,2,3,4,5]); -- 2.48.1 From e539f4f3af53af07cf9ef85fc0dfc3d5c006df3d Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Sat, 30 Sep 2023 12:48:34 +1000 Subject: [PATCH 3/3] Changed source link to go to Gitea --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 06b97bd..b47d8fa 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,6 @@ + source \ No newline at end of file -- 2.48.1