Building it up layer by layer
parent
c093c89ce6
commit
26f927daae
7
main.js
7
main.js
|
@ -35,11 +35,18 @@ scene.background = new THREE.Color(0x808080);
|
|||
const material = new THREE.MeshStandardMaterial({ color: 0x3293a9 });
|
||||
const node_colours = get_colours(0x3293a9);
|
||||
|
||||
console.log(node_colours);
|
||||
|
||||
material.transparent = true;
|
||||
material.opacity = 0.5;
|
||||
|
||||
|
||||
const node_ms = node_colours.map((c) => new THREE.MeshStandardMaterial({color: c}));
|
||||
|
||||
node_ms[0].transparent = true;
|
||||
node_ms[0].opacity = 0.0;
|
||||
|
||||
|
||||
const link_ms = [ material ];
|
||||
|
||||
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"vite": "^4.4.6"
|
||||
}
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
|
70
polytopes.js
70
polytopes.js
|
@ -384,42 +384,48 @@ function meridian_label_120cell(nodes) {
|
|||
|
||||
function arctic_label_120cell(nodes) {
|
||||
|
||||
const ARCTIC_COLOURED ={
|
||||
const ARCTIC_COLOURED = {
|
||||
'1': [
|
||||
49, 105, 131, 149, 165, 223,
|
||||
241, 253, 265, 279, 301, 313,
|
||||
325, 347, 367, 389, 413, 425,
|
||||
449, 453, 469, 473, 487, 513,
|
||||
581, 593
|
||||
27, 49, 61, 87, 95, 105, 131, 149, 165,
|
||||
174, 185, 210, 223, 226, 239, 241, 253, 263,
|
||||
265, 279, 285, 301, 311, 313, 325, 331, 347,
|
||||
357, 367, 369, 383, 389, 393, 406, 413, 419,
|
||||
425, 438, 449, 453, 469, 471, 473, 487, 511,
|
||||
513, 525, 530, 563, 566, 573, 581, 585, 593
|
||||
],
|
||||
'2': [
|
||||
1, 5, 7, 15, 19, 25, 35,
|
||||
37, 41, 53, 69, 85, 93, 97,
|
||||
109, 113, 129, 135, 145, 155, 157,
|
||||
161, 167, 173, 177, 209
|
||||
1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 23,
|
||||
24, 25, 31, 35, 37, 41, 50, 53, 57, 67, 69,
|
||||
73, 82, 83, 85, 91, 93, 97, 103, 109, 113, 119,
|
||||
123, 125, 129, 135, 141, 145, 150, 155, 157, 161, 167,
|
||||
170, 173, 177, 182, 189, 193, 199, 209, 214, 215
|
||||
],
|
||||
'3': [
|
||||
39, 45, 65, 117, 153, 219,
|
||||
245, 251, 269, 293, 317, 321,
|
||||
349, 375, 399, 417, 437, 441,
|
||||
445, 457, 485, 509, 515, 529,
|
||||
577, 597
|
||||
39, 45, 65, 86, 99, 117, 127, 137, 153,
|
||||
178, 197, 211, 219, 230, 235, 245, 251, 257,
|
||||
269, 273, 293, 312, 317, 321, 335, 343, 349,
|
||||
355, 363, 375, 385, 399, 405, 415, 417, 437,
|
||||
441, 445, 457, 475, 485, 498, 502, 509, 515,
|
||||
529, 547, 551, 562, 567, 569, 577, 589, 597
|
||||
],
|
||||
'4': [
|
||||
33, 101, 159, 169, 213, 221,
|
||||
229, 249, 271, 277, 329, 341,
|
||||
351, 361, 397, 409, 433, 461,
|
||||
477, 483, 517, 533, 545, 549,
|
||||
561, 583
|
||||
33, 54, 71, 77, 101, 115, 121, 146, 159,
|
||||
169, 195, 213, 221, 229, 237, 242, 249, 261,
|
||||
271, 277, 295, 309, 315, 322, 329, 341, 351,
|
||||
359, 361, 371, 390, 397, 408, 409, 423, 433,
|
||||
443, 447, 461, 477, 483, 489, 493, 507, 517,
|
||||
533, 545, 549, 553, 561, 575, 583, 595, 598
|
||||
],
|
||||
'5': [
|
||||
29, 81, 89, 133, 163, 181,
|
||||
217, 225, 255, 267, 303, 333,
|
||||
337, 345, 365, 373, 421, 429,
|
||||
465, 481, 497, 501, 505, 519,
|
||||
565, 579
|
||||
29, 81, 89, 133, 163, 181, 217, 225, 233,
|
||||
246, 255, 259, 267, 275, 287, 294, 303, 310,
|
||||
319, 326, 333, 337, 345, 353, 365, 373, 381,
|
||||
391, 395, 407, 411, 421, 429, 434, 451, 455,
|
||||
465, 467, 479, 481, 497, 501, 505, 519, 521,
|
||||
534, 537, 541, 557, 565, 571, 579, 594, 599
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
for( const cstr in ARCTIC_COLOURED ) {
|
||||
label_nodes(nodes, ARCTIC_COLOURED[cstr], Number(cstr));
|
||||
}
|
||||
|
@ -440,16 +446,16 @@ export const cell120 = () => {
|
|||
const nodes = make_120cell_vertices();
|
||||
const links = auto_detect_edges(nodes, 4);
|
||||
|
||||
meridian_label_120cell(nodes);
|
||||
arctic_label_120cell(nodes);
|
||||
|
||||
// const links = links_all.filter((l) => {
|
||||
// const labels = link_labels(nodes, l);
|
||||
// return ( labels[0] > 0 && labels[1] > 0 );
|
||||
// });
|
||||
const links_f = links.filter((l) => {
|
||||
const labels = link_labels(nodes, l);
|
||||
return ( labels[0] > 0 && labels[1] > 0 );
|
||||
});
|
||||
|
||||
return {
|
||||
nodes: nodes,
|
||||
links: links,
|
||||
links: links_f,
|
||||
geometry: {
|
||||
node_size: 0.02,
|
||||
link_size: 0.02
|
||||
|
|
159
testbed.js
159
testbed.js
|
@ -466,6 +466,19 @@ function find_adjacent_nodes(links, nid) {
|
|||
});
|
||||
}
|
||||
|
||||
function node_by_id(nodes, nid) {
|
||||
const ns = nodes.filter((n) => n.id === nid);
|
||||
return ns[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
function find_adjacent_labels(nodes, links, nid) {
|
||||
return find_adjacent_nodes(links, nid).map(
|
||||
(nid) => node_by_id(nodes, nid).label
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function colour_next_dodeca_maybe(nodes, links, faces, colours, dd, nextf, nextdd) {
|
||||
|
@ -575,6 +588,33 @@ function follow_meridian(nodes, links, faces, colours, odd, dir, max) {
|
|||
}
|
||||
|
||||
|
||||
function follow_and_colour(nodes, links, faces, colours, dd, face) {
|
||||
let nextdd = follow_face_to_dodeca(faces, dd, face);
|
||||
let ncolours = colour_next_dodeca_maybe(nodes, links, faces, colours, dd, face, nextdd);
|
||||
|
||||
if( !ncolours ) {
|
||||
nextdd = follow_face_to_dodeca(faces, dd, face, true);
|
||||
ncolours = colour_next_dodeca_maybe(nodes, links, faces, colours, dd, face, nextdd);
|
||||
if( !ncolours ) {
|
||||
console.log("two mismatches");
|
||||
}
|
||||
}
|
||||
return [ nextdd, ncolours ];
|
||||
}
|
||||
|
||||
|
||||
function add_colours(colours, ncolours) {
|
||||
for( const vertex in ncolours ) {
|
||||
if( vertex in colours ) {
|
||||
if( colours[vertex] !== ncolours[vertex] ) {
|
||||
console.log(`label mismatch at ${vertex}: ${colours[vertex]}/${ncolours[vertex]}`);
|
||||
}
|
||||
} else {
|
||||
colours[vertex] = ncolours[vertex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// "arctic circle" - this one works
|
||||
|
||||
|
@ -628,53 +668,70 @@ function arctic(nodes, links, faces, startf, startn, max) {
|
|||
|
||||
|
||||
|
||||
// this one breaks but I don't know if it's because of the traversal
|
||||
// algorithm or the indexing algorithm
|
||||
|
||||
function whole_120_cell(nodes, links, faces, startf, startn, max) {
|
||||
|
||||
function arctic_two(nodes, links, faces, startf, startn) {
|
||||
const pole = face_plus_to_dodecahedron(faces, startf, startn);
|
||||
const dds = [ pole ];
|
||||
const queue = [ pole ];
|
||||
|
||||
const seen = {};
|
||||
seen[dd_fingerprint(pole)] = true;
|
||||
|
||||
// colour first cell
|
||||
const colours = colour_dodecahedron_from_face(dds[0], [ 1, 2, 3, 4, 5 ] );
|
||||
const vs = dodecahedron_vertices(dds[0]);
|
||||
|
||||
const colours = colour_dodecahedron_from_face(pole, [ 1, 2, 3, 4, 5 ] );
|
||||
for( const face of pole ) {
|
||||
const [ nextdd, ncolours ] = follow_and_colour(
|
||||
nodes, links, faces, colours, pole, face
|
||||
);
|
||||
add_colours(colours, ncolours);
|
||||
dds.push(nextdd);
|
||||
seen[dd_fingerprint(nextdd)] = true;
|
||||
}
|
||||
|
||||
let ncolours = {};
|
||||
|
||||
while( ncolours && queue.length > 0 ) {
|
||||
const dd = queue.shift();
|
||||
for( const face of dd ) {
|
||||
let nextdd = follow_face_to_dodeca(faces, dd, face);
|
||||
// dumb!
|
||||
// top five of the temperate circle
|
||||
const a1 = dds[1];
|
||||
for( const a of dds.slice(1, 12) ) {
|
||||
for( const i of [ 6, 7, 8, 9, 10 ] ) {
|
||||
const [ nextdd, ncolours ] = follow_and_colour(
|
||||
nodes, links, faces, colours, a, a[i]
|
||||
);
|
||||
const fp = dd_fingerprint(nextdd);
|
||||
if( ! (fp in seen) ) {
|
||||
seen[fp] = true;
|
||||
ncolours = colour_next_dodeca_maybe(nodes, links, faces, colours, pole, face, nextdd);
|
||||
|
||||
if( !ncolours ) {
|
||||
nextdd = follow_face_to_dodeca(faces, pole, face, true);
|
||||
ncolours = colour_next_dodeca_maybe(nodes, links, faces, colours, pole, face, nextdd);
|
||||
if( !ncolours ) {
|
||||
console.log("two mismatches");
|
||||
}
|
||||
}
|
||||
for( const vertex in ncolours ) {
|
||||
if( vertex in colours ) {
|
||||
if( colours[vertex] !== ncolours[vertex] ) {
|
||||
console.log(`label mismatch at ${vertex}: ${colours[vertex]}/${ncolours[vertex]}`);
|
||||
}
|
||||
} else {
|
||||
colours[vertex] = ncolours[vertex];
|
||||
}
|
||||
}
|
||||
if( !(fp in seen) ) {
|
||||
add_colours(colours, ncolours);
|
||||
dds.push(nextdd);
|
||||
queue.push(nextdd);
|
||||
seen[fp] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // bottom five of the temperate circle
|
||||
// const a12 = dds[12];
|
||||
// for( const i of [ 6, 7, 8, 9, 10 ] ) {
|
||||
// const [ nextdd, ncolours ] = follow_and_colour(
|
||||
// nodes, links, faces, colours, a1, a1[i]
|
||||
// );
|
||||
// add_colours(colours, ncolours);
|
||||
// dds.push(nextdd);
|
||||
// }
|
||||
|
||||
// // will be weird
|
||||
// for( const dd of dds.slice(2, 12) ) {
|
||||
// const [ nextdd, ncolours ] = follow_and_colour(
|
||||
// nodes, links, faces, colours, dd, dd[6]
|
||||
// );
|
||||
// add_colours(colours, ncolours);
|
||||
// dds.push(nextdd);
|
||||
// }
|
||||
|
||||
// for( const dd of dds.slice(2, 7) ) {
|
||||
// const [ nextdd, ncolours ] = follow_and_colour(
|
||||
// nodes, links, faces, colours, dd, dd[6]
|
||||
// );
|
||||
// add_colours(colours, ncolours);
|
||||
// dds.push(nextdd);
|
||||
// }
|
||||
|
||||
|
||||
const labels = { 1: [], 2:[], 3:[], 4:[], 5:[] };
|
||||
for( const vstr in colours ) {
|
||||
|
@ -683,9 +740,6 @@ function whole_120_cell(nodes, links, faces, startf, startn, max) {
|
|||
|
||||
|
||||
return { dodecahedra: dds, labels: labels };
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -715,7 +769,7 @@ function face_to_dodecahedra(faces, f) {
|
|||
|
||||
function dd_fingerprint(dodecahedron) {
|
||||
const ids = dodecahedron.map((face) => face.id);
|
||||
ids.sort()
|
||||
ids.sort((a, b) => a - b);
|
||||
return ids.join(',');
|
||||
}
|
||||
|
||||
|
@ -792,12 +846,37 @@ function dodeca_nodes(dd) {
|
|||
}
|
||||
|
||||
|
||||
function label_nodes(nodes, ids, label) {
|
||||
nodes.filter((n) => ids.includes(n.id)).map((n) => n.label = label);
|
||||
}
|
||||
|
||||
function meridian_label_120cell(nodes) {
|
||||
|
||||
const MERIDIAN_COLOURED ={"1":[27,38,49,61,68,74,87,105,120,126,131,140,149,156,165,174,179,185,200,207,210,218,223,226,231,234,239,241,253,258,263,265,272,274,279,284,285,289,296,300,301,306,311,313,320,324,325,331,334,339,342,347,350,356,357,367,369,376,378,383,388,389,393,400,413,414,419,420,425,440,449,453,458,460,469,471,473,474,487,488,490,494,499,503,511,512,513,514,525,527,530,532,539,543,546,550,555,558,563,566,572,573,580,581,592,593],"2":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,21,22,23,24,25,28,30,31,34,35,37,40,41,46,47,50,51,53,56,57,60,62,63,66,67,69,72,73,76,78,83,85,88,90,93,97,103,106,107,109,112,113,116,118,119,122,123,125,129,132,134,135,138,139,141,144,145,148,150,151,155,157,160,161,164,166,167,170,171,173,177,180,182,183,187,189,192,193,196,198,202,203,205,208,209,212,214,215],"3":[26,39,45,52,64,65,94,99,108,117,127,130,137,152,153,168,175,178,188,197,206,211,219,222,227,230,235,238,245,251,268,269,273,280,283,286,292,293,299,302,305,312,316,317,321,328,330,335,349,355,358,363,366,370,375,377,384,385,392,394,399,404,405,415,416,417,418,426,437,439,441,445,452,456,457,459,470,472,475,485,486,491,495,498,502,509,510,515,516,526,529,531,538,542,547,551,554,559,562,567,569,576,577,584,588,597],"4":[32,33,43,54,58,71,77,84,101,110,115,121,136,143,146,159,162,169,184,204,213,220,221,228,229,236,237,249,260,261,271,276,277,281,288,290,295,297,304,308,309,315,318,322,327,329,336,340,341,351,354,359,361,368,371,374,379,382,387,390,396,397,409,410,423,424,430,433,435,443,447,450,454,461,463,466,468,477,478,483,484,489,493,500,504,507,508,517,518,522,533,535,540,544,545,549,553,560,561,568,570,583,587,590,595,598],"5":[29,36,42,55,59,70,80,81,89,111,114,133,142,147,163,181,191,194,201,216,217,224,225,232,233,240,243,246,255,267,270,275,278,282,287,291,294,298,303,307,310,314,319,323,326,332,333,337,344,345,352,353,360,364,365,372,373,380,381,395,398,402,407,411,412,421,422,429,436,442,446,451,455,462,464,465,467,479,481,482,492,496,497,501,505,506,519,520,521,523,534,536,537,541,548,552,556,557,564,565,574,579,586,591,594,599]};
|
||||
|
||||
|
||||
for( const cstr in MERIDIAN_COLOURED ) {
|
||||
label_nodes(nodes, MERIDIAN_COLOURED[cstr], Number(cstr));
|
||||
}
|
||||
|
||||
//label_nodes(nodes, [313], 6);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const nodes = make_120cell_vertices();
|
||||
const links = auto_detect_edges(nodes, 4);
|
||||
const faces = auto_120cell_faces(links);
|
||||
|
||||
//const dodecas = make_120cell_cells(faces);
|
||||
|
||||
const colours = all_meridians(nodes, links, faces, faces[0], 341);
|
||||
//const colours = all_meridians(nodes, links, faces, faces[0], 341);
|
||||
|
||||
console.log(JSON.stringify(colours));
|
||||
//console.log(JSON.stringify(colours));
|
||||
|
||||
|
||||
// note - all_meridians colours 530 of the 600 vertices - try a simple
|
||||
// algorithm to see which of the remaining 70 have 4 neighbours labeled and
|
||||
// fill in the rest that way
|
||||
|
||||
// have tried this and they mostly have 3 with some 1s and 2ss
|
Loading…
Reference in New Issue