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)); +// }