diff --git a/gui.js b/gui.js index 921a98f..cf202d5 100644 --- a/gui.js +++ b/gui.js @@ -45,7 +45,7 @@ class FourDGUI { }; this.gui.add(this.params, 'shape', - [ '5-cell', '16-cell', 'tesseract', + [ 'dodecahedron', '5-cell', '16-cell', 'tesseract', '24-cell', '600-cell', '120-cell' ] ).onChange(changeShape) this.gui.add(this.params, 'inscribed').onChange(changeShape); diff --git a/index.html b/index.html index 06b97bd..b47d8fa 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,6 @@
by Mike Lynch - - source
+ source \ No newline at end of file diff --git a/main.js b/main.js index 3282f19..ab2abd5 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(), }; @@ -73,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 = { @@ -80,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 39736f0..6d80f0a 100644 --- a/polytopes.js +++ b/polytopes.js @@ -652,8 +652,52 @@ const cell600_some_inscribed = (ps) => { link_size: 0.02 }, } +} +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, 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, 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, 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 , 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 , 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); + return nodes; +} + +export const dodecahedron = () => { + const nodes = make_dodecahedron_vertices(); + const links = auto_detect_edges(nodes, 3); + return { nodes: nodes, links: links, @@ -664,7 +708,30 @@ const cell600_some_inscribed = (ps) => { } } +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); -export const cell600_inscribed = () => cell600_some_inscribed([1]); -export const cell600_all_inscribed = () => cell600_some_inscribed([1,2,3,4,5]); + 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]); 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)); +// }