feature-update-link #3

Merged
bombinans merged 3 commits from feature-update-link into main 2023-09-30 02:53:17 +00:00
5 changed files with 103 additions and 15 deletions

2
gui.js
View File

@ -45,7 +45,7 @@ class FourDGUI {
}; };
this.gui.add(this.params, 'shape', this.gui.add(this.params, 'shape',
[ '5-cell', '16-cell', 'tesseract', [ 'dodecahedron', '5-cell', '16-cell', 'tesseract',
'24-cell', '600-cell', '120-cell' ] '24-cell', '600-cell', '120-cell' ]
).onChange(changeShape) ).onChange(changeShape)
this.gui.add(this.params, 'inscribed').onChange(changeShape); this.gui.add(this.params, 'inscribed').onChange(changeShape);

View File

@ -17,6 +17,6 @@
<body> <body>
<script type="module" src="/main.js"></script> <script type="module" src="/main.js"></script>
<div id="info">by <a target="_blank" href="https://mikelynch.org/">Mike Lynch</a> - <div id="info">by <a target="_blank" href="https://mikelynch.org/">Mike Lynch</a> -
<a target="_blank" href="https://github.com/spikelynch/fourdjs">source</a></div> <a target="_blank" href="https://git.tilde.town/bombinans/fourdjs">source</a></div>
</body> </body>
</html> </html>

View File

@ -64,6 +64,7 @@ const STRUCTURES = {
'16-cell': POLYTOPES.cell16(), '16-cell': POLYTOPES.cell16(),
'tesseract': POLYTOPES.tesseract(), 'tesseract': POLYTOPES.tesseract(),
'24-cell': POLYTOPES.cell24(), '24-cell': POLYTOPES.cell24(),
'dodecahedron': POLYTOPES.dodecahedron(),
'120-cell': POLYTOPES.cell120(), '120-cell': POLYTOPES.cell120(),
'600-cell': POLYTOPES.cell600(), '600-cell': POLYTOPES.cell600(),
}; };
@ -73,6 +74,7 @@ const INSCRIBED = {
'24-cell': POLYTOPES.cell24_inscribed(), '24-cell': POLYTOPES.cell24_inscribed(),
'120-cell': POLYTOPES.cell120_inscribed(), '120-cell': POLYTOPES.cell120_inscribed(),
'600-cell': POLYTOPES.cell600_inscribed(), '600-cell': POLYTOPES.cell600_inscribed(),
'dodecahedron': POLYTOPES.dodecahedron_inscribed(),
}; };
const ALL_INSCRIBED = { const ALL_INSCRIBED = {
@ -80,6 +82,7 @@ const ALL_INSCRIBED = {
'24-cell': POLYTOPES.cell24_all_inscribed(), '24-cell': POLYTOPES.cell24_all_inscribed(),
'120-cell': POLYTOPES.cell120_all_inscribed(), '120-cell': POLYTOPES.cell120_all_inscribed(),
'600-cell': POLYTOPES.cell600_all_inscribed(), '600-cell': POLYTOPES.cell600_all_inscribed(),
'dodecahedron': POLYTOPES.dodecahedron_all_inscribed(),
} }
let shape = false; let shape = false;

View File

@ -652,8 +652,52 @@ const cell600_some_inscribed = (ps) => {
link_size: 0.02 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 { return {
nodes: nodes, nodes: nodes,
links: links, 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]); for( const p of ps) {
export const cell600_all_inscribed = () => cell600_some_inscribed([1,2,3,4,5]); 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]);

View File

@ -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 nodes = make_120cell_vertices();
const links = auto_detect_edges(nodes, 4); // const links = auto_detect_edges(nodes, 4);
const faces = auto_120cell_faces(links); // 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"); // console.log("labelling nodes");
for( const cstr in labels ) { // for( const cstr in labels ) {
label_nodes(nodes, labels[cstr], Number(cstr)); // label_nodes(nodes, labels[cstr], Number(cstr));
} // }