Refactoring the code which finds coherent sets of 5-cells

This commit is contained in:
Mike Lynch 2026-01-01 17:05:23 +11:00
parent 264aa5e497
commit a395006523
2 changed files with 56 additions and 28 deletions

View File

@ -117,7 +117,17 @@ export const CELL120_CELL5 = {
"2": [ 223, 76, 238, 84, 225 ],
"3": [ 253, 44, 283, 304, 42 ],
"4": [ 419, 112, 197, 578, 521 ],
"5": [ 339, 14, 384, 382, 337 ],
"6": [ 331, 4, 335, 390, 386 ],
"7": [ 427, 160, 551, 146, 557 ],
"8": [ 265, 60, 64, 295, 246 ],
"9": [ 473, 100, 495, 213, 462 ],
"10": [ 393, 6, 328, 397, 326 ],
"11": [ 539, 164, 439, 561, 142 ],
"12": [ 511, 122, 456, 595, 181 ],
"13": [ 555, 154, 152, 545, 429 ]
},
};

View File

@ -114,6 +114,15 @@ function overlap(c1, c2) {
return false;
}
function c5match(c1, c2) {
for( const l in c1 ) {
if( c1[l] != c2[l] ) {
return false;
}
}
return true;
}
export function gather_5cells(cell120) {
const CHORD5 = round_dist(Math.sqrt(2.5));
@ -379,30 +388,13 @@ function cell5_neighbourhoods(cell120, all5, c5) {
}
// pick a 5-cell, and then pick the nearest neighbours to its vertices on their
// respective inscribed 600-cells
const cell120 = POLYTOPES.cell120_inscribed();
const all5 = gather_5cells(cell120);
const c5 = all5[0]
function cell5_tetras(cell120, all5, c5) {
const nb = cell5_neighbourhoods(cell120, all5, c5);
// trying for all tetras
// let's pick a tetra on the first vertex of the primary 5cell...
const v1 = cell120node(cell120, c5["1"]);
const ts = tetras(cell120, v1);
const c5s = [];
for( const t of ts ) {
console.log(t);
// ... and then see which of the neighbourhood 5-cells have at least one
// of its vertices
const nt = nb.filter((n) => {
for( const l in n ) {
if( t.includes(n[l]) ) {
@ -411,7 +403,33 @@ for( const t of ts ) {
}
return false
});
console.log(nt);
console.log("\n");
for( const nc5 of nt ) {
const exact = c5s.filter((c) => c5match(c, nc5));
if( exact.length === 0 ) {
const o = c5s.filter((c) => overlap(c, nc5));
if( o.length > 0 ) {
console.log("Overlap", c5, o);
} else {
c5s.push(nc5);
}
}
}
}
return c5s;
}
const cell120 = POLYTOPES.cell120_inscribed();
const all5 = gather_5cells(cell120);
const c5 = all5[0]
const c5s = cell5_tetras(cell120, all5, c5);
const celli = c5s.map((c5) => [ "1", "2", "3", "4", "5" ].map((l) => c5[l]));
console.log(celli);