From aba20124db74f8eb6e2b5ff55490660e9a1275c4 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Thu, 25 Apr 2024 10:57:03 +1000 Subject: [PATCH] Normalised 5-cell and 16-cell to unit radius --- polytopes.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/polytopes.js b/polytopes.js index 15c6d2f..a1156e8 100644 --- a/polytopes.js +++ b/polytopes.js @@ -58,16 +58,15 @@ export function auto_detect_edges(nodes, neighbours, debug=false) { // too small and simple to calculate export const cell5 = () => { - const r5 = Math.sqrt(5); - const r2 = Math.sqrt(2) / 2; + const c1 = Math.sqrt(5) / 4; return { name: '5-cell', nodes: [ - {id:1, label: 1, x: r2, y: r2, z: r2, w: -r2 / r5 }, - {id:2, label: 2, x: r2, y: -r2, z: -r2, w: -r2 / r5 }, - {id:3, label: 3, x: -r2, y: r2, z: -r2, w: -r2 / r5 }, - {id:4, label: 4, x: -r2, y: -r2, z: r2, w: -r2 / r5 }, - {id:5, label: 5, x: 0, y: 0, z: 0, w: 4 * r2 / r5 }, + {id:1, label: 1, x: c1, y: c1, z: c1, w: -0.25 }, + {id:2, label: 2, x: c1, y: -c1, z: -c1, w: -0.25 }, + {id:3, label: 3, x: -c1, y: c1, z: -c1, w: -0.25 }, + {id:4, label: 4, x: -c1, y: -c1, z: c1, w: -0.25 }, + {id:5, label: 5, x: 0, y: 0, z: 0, w: 1 }, ], links: [ { id:1, source:1, target: 2}, @@ -109,7 +108,7 @@ export const cell16 = () => { nodes[1].label = 4; index_nodes(nodes); - scale_nodes(nodes, 0.75); + scale_nodes(nodes, 0.5); const links = auto_detect_edges(nodes, 6); return { @@ -767,4 +766,8 @@ export const build_all = () => { cell120_inscribed(), cell120_layered() ]; +} + +export const radii = (shape) => { + return shape.nodes.map(n => Math.sqrt(n.x * n.x + n.y * n.y + n.z * n.z + n.w * n.w)) } \ No newline at end of file