New idea doesn't quite work

This commit is contained in:
Mike Lynch 2025-11-26 19:02:09 +11:00
parent 78b79503f9
commit 5922a5df60

172
explore_120cell.js Normal file
View File

@ -0,0 +1,172 @@
import * as POLYTOPES from './polytopes.js';
// exploring more inscriptions of the 120-cell
export function nodes_links(links, nodeid) {
return links.filter((l) => l.source === nodeid || l.target === nodeid);
}
export function linked(links, n1, n2) {
const ls = nodes_links(nodes_links(links, n1), n2);
if( ls.length ) {
return ls[0]
} else {
return false;
}
}
function fingerprint(ids) {
const sids = [...ids];
sids.sort();
return sids.join(',');
}
export function dist(n1, n2) {
return Math.sqrt((n1.x - n2.x) ** 2 + (n1.y - n2.y) ** 2 + (n1.z - n2.z) ** 2 + (n1.w - n2.w) ** 2);
}
export function make_120cell() {
const nodes = POLYTOPES.make_120cell_vertices();
const links = POLYTOPES.auto_detect_edges(nodes, 4);
return {
nodes: nodes,
links: links
}
}
function round_dist(raw) {
return Math.floor(raw * 100000) / 100000;
}
export function distance_groups(cell120) {
// get list of other nodes by distance
// sort them and dump them out
const dists = {};
cell120.nodes.map((n) => {
const draw = dist(cell120.nodes[0], n);
const dtrunc = round_dist(draw);
if( !(dtrunc in dists) ) {
dists[dtrunc] = [];
}
dists[dtrunc].push(n);
});
return dists;
}
function distance_group(cell120, n0, chord) {
const nodes = []
cell120.nodes.map((n) => {
const d = round_dist(dist(n0, n));
if( d == chord ) {
nodes.push(n);
}
});
// filter and return those whose chord is also the same
const equidistant = [];
for( const n1 of nodes ) {
for( const n2 of nodes ) {
if( n2.id > n1.id ) {
if( round_dist(dist(n1, n2)) == chord ) {
equidistant.push([n1, n2]);
}
}
}
}
return equidistant;
}
export function chord_survey() {
const cell120 = POLYTOPES.cell120_inscribed();
const dgroups = distance_groups(cell120);
const dists = Object.keys(dgroups);
dists.sort();
for( const d of dists ) {
const g0 = dgroups[d][0];
dgroups[d].map((g) => {
console.log(`${g0.id}-${g.id}: ${round_dist(dist(g0, g))}`);
});
}
}
// how to proceed: start with the 120-cell that has five 600-cells inscribed
// in it. Take the 120 nodes from one of those 600-cells, and construct a 5-cell
// from each such that all of the vertices are on different 600-cells.
// collect them and output by label because every 5-cell is on all 5 600-cells
function overlap(c1, c2) {
for( const l in c1 ) {
if( c1[l] === c2[l] ) {
return true;
}
}
return overlap;
}
export function gather_5cells() {
const cell120 = POLYTOPES.cell120_inscribed();
const CHORD5 = round_dist(Math.sqrt(2.5));
const bins = [];
cell120.nodes.filter((n) => n.label === 1).map((n) => {
const g = distance_group(cell120, n, CHORD5);
const cells = [ ];
for( const pair of g ) {
let seen = false;
for( const cell of cells ) {
const c = Object.values(cell);
if( c.includes(pair[0].id) || c.includes(pair[1].id) ) {
if( !c.includes(pair[0].id) ) {
cell[pair[0].label] = pair[0].id;
}
if( !c.includes(pair[1].id) ) {
cell[pair[1].label] = pair[1].id;
}
seen = true;
break;
}
}
if( !seen ) {
const cell = {};
cell[1]= n.id;
cell[pair[0].label] = pair[0].id;
cell[pair[1].label] = pair[1].id;
cells.push(cell);
}
}
for( const cell of cells ) {
let binned = false;
for( const bin of bins ) {
const overlaps = bin.filter((b) => overlap(b, cell));
console.log(bin);
console.log(cell);
console.log(overlaps);
if( overlaps.length === 0 ) {
bin.push(cell);
binned = true;
console.log("binned");
break;
}
}
if( !binned ) {
bins.push([ cell ]);
}
}
//console.log(bins);
})
;
}
gather_5cells();