Compare commits
No commits in common. "203850ba391ad0bd162cb532a0828458fd1204b6" and "bf8356b0a265c5894d372d599938670daf67850b" have entirely different histories.
203850ba39
...
bf8356b0a2
102
cellindex.js
102
cellindex.js
|
@ -1,101 +1 @@
|
|||
export const INDEX = {
|
||||
"1": [
|
||||
27,38,48,49,61,68,74,87,95,98,105,120, 126,131,140,149,156,165,174,
|
||||
179,185,200,207,210,218,223,226,231,234,239,241,248,252,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,362,367,369,376,378,383,388,389,393,400,
|
||||
403,406,413,414,419,420,425,427,438,440,444,448,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,585,592,593,600
|
||||
],
|
||||
"2":[
|
||||
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,28,
|
||||
30,31,34,35,37,40,41,44,46,47,50,51,53,56,57,60,62,63,66,67,69,72,73,
|
||||
76,78,79,82,83,85,88,90,91,93,96,97,100,102,103,106,107,109,112,113,
|
||||
116,118,119,122,123,125,128,129,132,134,135,138,139,141,144,145,148,
|
||||
150,151,154,155,157,160,161,164,166,167,170,171,173,176,177,180,182,
|
||||
183,186,187,189,192,193,196,198,199,202,203,205,208,209,212,214,215
|
||||
],
|
||||
"3":[
|
||||
26,39,45,52,64,65,75,86,94,99,108,117,127,130,137,152,153,168,175,
|
||||
178,188,197,206,211,219,222,227,230,235,238,244,245,251,254,257,264,
|
||||
268,269,273,280,283,286,292,293,299,302,305,312,316,317,321,328,330,
|
||||
335,338,343,348,349,355,358,363,366,370,375,377,384,385,392,394,399,
|
||||
404,405,415,416,417,418,426,428,437,439,441,445,452,456,457,459,470,
|
||||
472,475,476,485,486,491,495,498,502,509,510,515,516,526,528,529,531,
|
||||
538,542,547,551,554,559,562,567,569,576,577,584,588,589,596,597
|
||||
],
|
||||
"4":[
|
||||
32,33,43,54,58,71,77,84,92,101,110,115,121,136,143,146,159,162,169,
|
||||
184,190,195,204,213,220,221,228,229,236,237,242,247,249,256,260,261,
|
||||
266,271,276,277,281,288,290,295,297,304,308,309,315,318,322,327,329,
|
||||
336,340,341,346,351,354,359,361,368,371,374,379,382,387,390,396,397,
|
||||
401,408,409,410,423,424,430,432,433,435,443,447,450,454,461,463,466,
|
||||
468,477,478,483,484,489,493,500,504,507,508,517,518,522,524,533,535,
|
||||
540,544,545,549,553,560,561,568,570,575,578,583,587,590,595,598
|
||||
],
|
||||
"5":[
|
||||
29,36,42,55,59,70,80,81,89,104,111,114,124,133,142,147,158,163,172,
|
||||
181,191,194,201,216,217,224,225,232,233,240,243,246,250,255,259,262,
|
||||
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,386,391,395,398,
|
||||
402,407,411,412,421,422,429,431,434,436,442,446,451,455,462,464,465,
|
||||
467,479,480,481,482,492,496,497,501,505,506,519,520,521,523,534,536,
|
||||
537,541,548,552,556,557,564,565,571,574,579,582,586,591,594,599
|
||||
]
|
||||
};
|
||||
|
||||
export const LAYERS = {
|
||||
"0": [
|
||||
1,317,221,217,313,341,465,417,469,421,37,165,161,269,33,513,113,
|
||||
117,517,365
|
||||
],
|
||||
"1": [
|
||||
337,457,409,25,153,265,157,29,413,461,105,109,505,361,509,245,241,
|
||||
49,177,97,433,89,41,425,169,225,321,93,101,53,437,181,45,173,429,
|
||||
325,229,251,255,485,351,453,477,445,347,7,333,249,253,271,163,167,
|
||||
267,155,219,223,159,481,449,349,473,345,441,329,5,529,561,81,577,
|
||||
129,65,545,497,145,593,533,565,389,373,277,279,375,19,581,133,85,
|
||||
69,501,549,597,149,15,367,399,39,519,583,135,487,397,579,515,35,
|
||||
483,131,303,301,209,293,213
|
||||
],
|
||||
"2":[
|
||||
521,553,385,557,525,273,275,369,17,371,569,121,73,57,489,537,585,
|
||||
137,13,363,393,27,507,571,123,475,573,125,395,575,511,31,479,127,
|
||||
77,61,541,493,141,589,178,226,170,174,242,230,182,246,9,322,357,
|
||||
498,434,50,530,146,353,257,185,261,193,233,11,355,359,263,259,189,
|
||||
237,197,326,54,438,502,150,534,335,447,455,95,103,415,319,423,239,
|
||||
71,199,551,383,287,419,315,411,331,443,451,99,91,3,343,471,467,115,
|
||||
119,235,67,547,195,285,381,405,309,594,390,562,294,210,82,23,406,
|
||||
595,310,211,83,566,86,214,598,407,311,24,408,312,599,87,215,567,
|
||||
563,295,391
|
||||
],
|
||||
"3":[
|
||||
297,201,299,205,289,42,426,490,138,522,494,430,46,526,142,63,543,
|
||||
191,283,379,339,459,463,111,107,59,187,539,377,281,546,382,286,194,
|
||||
66,114,118,466,342,470,384,288,550,70,198,503,439,55,535,151,51,435,
|
||||
499,147,531,212,296,302,304,216
|
||||
],
|
||||
"4":[
|
||||
386,554,290,74,202,586,401,305,558,78,590,206,307,403,21,402,306,
|
||||
587,75,203,555,79,559,207,291,387,591,308,404,22,462,338,458,110,
|
||||
106,2,410,314,418,98,90,450,58,186,442,330,234,282,378,538,62,190,
|
||||
238,94,102,446,334,454,284,380,542,422,414,318,495,431,327,260,264,
|
||||
356,12,360,47,527,143,200,192,240,43,427,323,247,243,171,227,179,491,
|
||||
523,139,183,175,231,258,262,358,354,10,196,236,188,130,578,398,596,
|
||||
548,132,580,84,514,34,482,148,68,500,582,518,400,366,16,134,486,38,
|
||||
600,552,88,136,584,152,72,504,20,376,392,536,568,374,278,280,532,564
|
||||
],
|
||||
"5":[
|
||||
570,394,298,300,506,14,362,396,574,510,122,474,26,204,208,292,126,
|
||||
30,478,588,540,76,124,572,140,60,492,18,370,388,524,556,372,276,274,
|
||||
592,144,80,528,560,544,64,496,222,218,154,266,158,162,270,166,6,346,
|
||||
350,254,250,332,452,484,444,476,8,348,336,448,480,128,352,488,456,
|
||||
252,256,328,232,432,176,48,440,56,184,104,96,324,228,172,428,44,
|
||||
180,52,436,248,244,92,100,516,368,36,272,164,116,520,120,468,420,
|
||||
40,168,472,424,344
|
||||
],
|
||||
"6":[364,268,508,28,156,576,512,108,112,32,160,460,412,464,340,416,
|
||||
220,224,316,320,4
|
||||
]
|
||||
}
|
||||
export const INDEX = {"1": [ 27,38,48,49,61,68,74,87,95,98,105,120, 126,131,140,149,156,165,174,179,185,200,207,210,218,223,226,231,234,239,241,248,252,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,362,367,369,376,378,383,388,389,393,400,403,406,413,414,419,420,425,427,438,440,444,448,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,585,592,593,600],"2":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,28,30,31,34,35,37,40,41,44,46,47,50,51,53,56,57,60,62,63,66,67,69,72,73,76,78,79,82,83,85,88,90,91,93,96,97,100,102,103,106,107,109,112,113,116,118,119,122,123,125,128,129,132,134,135,138,139,141,144,145,148,150,151,154,155,157,160,161,164,166,167,170,171,173,176,177,180,182,183,186,187,189,192,193,196,198,199,202,203,205,208,209,212,214,215],"3":[26,39,45,52,64,65,75,86,94,99,108,117,127,130,137,152,153,168,175,178,188,197,206,211,219,222,227,230,235,238,244,245,251,254,257,264,268,269,273,280,283,286,292,293,299,302,305,312,316,317,321,328,330,335,338,343,348,349,355,358,363,366,370,375,377,384,385,392,394,399,404,405,415,416,417,418,426,428,437,439,441,445,452,456,457,459,470,472,475,476,485,486,491,495,498,502,509,510,515,516,526,528,529,531,538,542,547,551,554,559,562,567,569,576,577,584,588,589,596,597],"4":[32,33,43,54,58,71,77,84,92,101,110,115,121,136,143,146,159,162,169,184,190,195,204,213,220,221,228,229,236,237,242,247,249,256,260,261,266,271,276,277,281,288,290,295,297,304,308,309,315,318,322,327,329,336,340,341,346,351,354,359,361,368,371,374,379,382,387,390,396,397,401,408,409,410,423,424,430,432,433,435,443,447,450,454,461,463,466,468,477,478,483,484,489,493,500,504,507,508,517,518,522,524,533,535,540,544,545,549,553,560,561,568,570,575,578,583,587,590,595,598],"5":[29,36,42,55,59,70,80,81,89,104,111,114,124,133,142,147,158,163,172,181,191,194,201,216,217,224,225,232,233,240,243,246,250,255,259,262,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,386,391,395,398,402,407,411,412,421,422,429,431,434,436,442,446,451,455,462,464,465,467,479,480,481,482,492,496,497,501,505,506,519,520,521,523,534,536,537,541,548,552,556,557,564,565,571,574,579,582,586,591,594,599]};
|
||||
|
|
|
@ -61,7 +61,7 @@ class FourDShape extends THREE.Group {
|
|||
return edge;
|
||||
}
|
||||
|
||||
updateLink(link, links_show) {
|
||||
updateLink(link) {
|
||||
const n1 = this.nodes3[link.source].v3;
|
||||
const n2 = this.nodes3[link.target].v3;
|
||||
const length = n1.distanceTo(n2);
|
||||
|
@ -71,7 +71,6 @@ class FourDShape extends THREE.Group {
|
|||
link.object.position.copy(centre);
|
||||
link.object.lookAt(n2);
|
||||
link.object.children[0].rotation.x = Math.PI / 2.0;
|
||||
link.object.visible = (!links_show || link.label in links_show);
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +115,6 @@ class FourDShape extends THREE.Group {
|
|||
const material = this.getMaterial(n, this.node_ms);
|
||||
this.nodes3[n.id] = {
|
||||
v3: v3,
|
||||
label: n.label,
|
||||
object: this.makeNode(material, v3)
|
||||
};
|
||||
}
|
||||
|
@ -131,17 +129,17 @@ class FourDShape extends THREE.Group {
|
|||
}
|
||||
|
||||
|
||||
render3(rotations, nodes_show, links_show) {
|
||||
render3(rotations) {
|
||||
this.scalev3 = new THREE.Vector3(this.node_scale, this.node_scale, this.node_scale);
|
||||
for( const n of this.nodes4 ) {
|
||||
const v3 = this.fourDtoV3(n.x, n.y, n.z, n.w, rotations);
|
||||
this.nodes3[n.id].v3 = v3;
|
||||
this.nodes3[n.id].object.position.copy(v3);
|
||||
this.nodes3[n.id].object.scale.copy(this.scalev3);
|
||||
this.nodes3[n.id].object.visible = ( !nodes_show || n.label in nodes_show );
|
||||
}
|
||||
|
||||
for( const l of this.links ) {
|
||||
this.updateLink(l, links_show);
|
||||
this.updateLink(l);
|
||||
}
|
||||
|
||||
for( const f of this.faces ) {
|
||||
|
@ -149,6 +147,7 @@ class FourDShape extends THREE.Group {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export { FourDShape };
|
||||
|
|
38
gui.js
38
gui.js
|
@ -1,13 +1,13 @@
|
|||
import { GUI } from 'lil-gui';
|
||||
|
||||
|
||||
|
||||
const DEFAULTS = {
|
||||
thickness: 0.25,
|
||||
nodesize: 1.25,
|
||||
linkopacity: 0.5,
|
||||
link2opacity: 0.5,
|
||||
shape: '120-cell inscribed',
|
||||
visibility: 5,
|
||||
shape: '120-cell',
|
||||
inscribed: false,
|
||||
inscribe_all: false,
|
||||
color: 0x3293a9,
|
||||
|
@ -22,7 +22,7 @@ const DEFAULTS = {
|
|||
|
||||
class FourDGUI {
|
||||
|
||||
constructor(shapes, changeShape, setColor, setBackground, setLinkOpacity, setVisibility) {
|
||||
constructor(changeShape, setColor, setBackground, setLinkOpacity) {
|
||||
this.gui = new GUI();
|
||||
this.parseLinkParams();
|
||||
const guiObj = this;
|
||||
|
@ -34,7 +34,6 @@ class FourDGUI {
|
|||
linkopacity: this.link['linkopacity'],
|
||||
link2opacity: this.link['linkopacity'],
|
||||
nodesize: this.link['nodesize'],
|
||||
depth: this.link['depth'],
|
||||
color: this.link['color'],
|
||||
background: this.link['background'],
|
||||
hyperplane: this.link['hyperplane'],
|
||||
|
@ -44,19 +43,13 @@ class FourDGUI {
|
|||
dpsi: this.link['dpsi'],
|
||||
"copy link": function () { guiObj.copyUrl() }
|
||||
};
|
||||
const SHAPE_NAMES = shapes.map((s) => s.name);
|
||||
let options_ctrl;
|
||||
this.gui.add(this.params, 'shape', SHAPE_NAMES).onChange((shape) => {
|
||||
const options = this.getShapeOptions(shapes, shape);
|
||||
options_ctrl = options_ctrl.options(options).onChange((option) => {
|
||||
setVisibility(option)
|
||||
});
|
||||
changeShape(shape)
|
||||
});
|
||||
const options = this.getShapeOptions(shapes, this.params['shape']);
|
||||
options_ctrl = this.gui.add(this.params, 'options', options).onChange((option) => {
|
||||
setVisibility(option)
|
||||
});
|
||||
|
||||
this.gui.add(this.params, 'shape',
|
||||
[ 'dodecahedron', '5-cell', '16-cell', 'tesseract',
|
||||
'24-cell', '600-cell', '120-cell' ]
|
||||
).onChange(changeShape)
|
||||
this.gui.add(this.params, 'inscribed').onChange(changeShape);
|
||||
this.gui.add(this.params, 'inscribe_all').onChange(changeShape);
|
||||
this.gui.add(this.params, 'hyperplane', 1.5, 2.25);
|
||||
this.gui.add(this.params, 'thickness', 0.1, 2);
|
||||
this.gui.add(this.params, 'linkopacity', 0, 1).onChange(
|
||||
|
@ -74,15 +67,6 @@ class FourDGUI {
|
|||
|
||||
}
|
||||
|
||||
getShapeOptions(shapes, shape) {
|
||||
const spec = shapes.filter((s) => s.name === shape);
|
||||
if( spec && spec[0].options ) {
|
||||
return spec[0].options.map((o) => o.name);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
numParam(param, parser) {
|
||||
const value = this.urlParams.get(param);
|
||||
|
@ -111,7 +95,7 @@ class FourDGUI {
|
|||
const guiObj = this;
|
||||
|
||||
this.urlParams = this.linkUrl.searchParams;
|
||||
for( const param of [ "shape", "rotation", "visiblity" ]) {
|
||||
for( const param of [ "shape", "rotation" ]) {
|
||||
const value = this.urlParams.get(param);
|
||||
if( value ) {
|
||||
this.link[param] = value;
|
||||
|
|
73
main.js
73
main.js
|
@ -23,9 +23,6 @@ scene.add(light);
|
|||
const amblight = new THREE.AmbientLight(0xffffff, 0.5);
|
||||
scene.add(amblight);
|
||||
|
||||
camera.position.set(1, 1, 3);
|
||||
|
||||
camera.lookAt(0, 0, 0);
|
||||
camera.position.z = 4;
|
||||
|
||||
const renderer = new THREE.WebGLRenderer({antialias: true});
|
||||
|
@ -62,26 +59,51 @@ for( const face_m of face_ms ) {
|
|||
}
|
||||
|
||||
|
||||
const STRUCTURES = [ POLYTOPES.cell120_inscribed() ];
|
||||
const STRUCTURES = {
|
||||
'5-cell': POLYTOPES.cell5(),
|
||||
'16-cell': POLYTOPES.cell16(),
|
||||
'tesseract': POLYTOPES.tesseract(),
|
||||
'24-cell': POLYTOPES.cell24(),
|
||||
'dodecahedron': POLYTOPES.dodecahedron(),
|
||||
'120-cell': POLYTOPES.cell120(),
|
||||
'600-cell': POLYTOPES.cell600(),
|
||||
};
|
||||
|
||||
const STRUCTURES_BY_NAME = {};
|
||||
const INSCRIBED = {
|
||||
'tesseract': POLYTOPES.tesseract_inscribed(),
|
||||
'24-cell': POLYTOPES.cell24_inscribed(),
|
||||
'120-cell': POLYTOPES.cell120_inscribed(),
|
||||
'600-cell': POLYTOPES.cell600_inscribed(),
|
||||
'dodecahedron': POLYTOPES.dodecahedron_inscribed(),
|
||||
};
|
||||
|
||||
STRUCTURES.map((s) => STRUCTURES_BY_NAME[s.name] = s);
|
||||
const ALL_INSCRIBED = {
|
||||
'tesseract': POLYTOPES.tesseract_all_inscribed(),
|
||||
'24-cell': POLYTOPES.cell24_all_inscribed(),
|
||||
'120-cell': POLYTOPES.cell120_all_inscribed(),
|
||||
'600-cell': POLYTOPES.cell600_all_inscribed(),
|
||||
'dodecahedron': POLYTOPES.dodecahedron_all_inscribed(),
|
||||
}
|
||||
|
||||
let shape = false;
|
||||
let structure = false;
|
||||
let node_show = [];
|
||||
let link_show = [];
|
||||
|
||||
|
||||
function createShape(name) {
|
||||
function createShape(name, inscribed, all) {
|
||||
if( shape ) {
|
||||
scene.remove(shape);
|
||||
}
|
||||
structure = STRUCTURES_BY_NAME[name];
|
||||
let structure = STRUCTURES[name];
|
||||
if( inscribed ) {
|
||||
if( name in INSCRIBED ) {
|
||||
if( all ) {
|
||||
structure = ALL_INSCRIBED[name];
|
||||
} else {
|
||||
structure = INSCRIBED[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shape = new FourDShape(node_ms, link_ms, face_ms, structure);
|
||||
scene.add(shape);
|
||||
setVisibility(structure.options[0].name);
|
||||
}
|
||||
|
||||
// initialise gui and read params from URL
|
||||
|
@ -114,27 +136,12 @@ function setLinkOpacity(o, primary) {
|
|||
|
||||
let gui; //
|
||||
|
||||
|
||||
function changeShape() {
|
||||
createShape(gui.params.shape);
|
||||
console.log("change shape!")
|
||||
createShape(gui.params.shape, gui.params.inscribed, gui.params.inscribe_all);
|
||||
}
|
||||
|
||||
function setVisibility(option_name) {
|
||||
const option = structure.options.filter((o) => o.name === option_name);
|
||||
node_show = option[0].nodes;
|
||||
link_show = option[0].links;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gui = new FourDGUI(
|
||||
STRUCTURES,
|
||||
changeShape,
|
||||
setColors,
|
||||
setBackground,
|
||||
setLinkOpacity,
|
||||
setVisibility
|
||||
);
|
||||
gui = new FourDGUI(changeShape, setColors, setBackground, setLinkOpacity);
|
||||
|
||||
// these are here to pick up colour settings from the URL params
|
||||
setColors(gui.params.color);
|
||||
|
@ -177,7 +184,7 @@ renderer.domElement.addEventListener("pointerup", (event) => {
|
|||
dragging = false;
|
||||
})
|
||||
|
||||
createShape(gui.params.shape);
|
||||
createShape(gui.params.shape, gui.params.inscribed, gui.params.inscribe_all);
|
||||
|
||||
function animate() {
|
||||
requestAnimationFrame( animate );
|
||||
|
@ -196,7 +203,7 @@ function animate() {
|
|||
shape.hyperplane = gui.params.hyperplane;
|
||||
shape.link_scale = gui.params.thickness;
|
||||
shape.node_scale = gui.params.nodesize;
|
||||
shape.render3(rotations, node_show, link_show);
|
||||
shape.render3(rotations);
|
||||
|
||||
renderer.render( scene, camera );
|
||||
}
|
||||
|
|
86
polytopes.js
86
polytopes.js
|
@ -61,7 +61,6 @@ export const cell5 = () => {
|
|||
const r5 = Math.sqrt(5);
|
||||
const r2 = Math.sqrt(2) / 2;
|
||||
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 },
|
||||
|
@ -107,7 +106,6 @@ export const cell16 = () => {
|
|||
const links = auto_detect_edges(nodes, 6);
|
||||
|
||||
return {
|
||||
name: '16-cell',
|
||||
nodes: nodes,
|
||||
links: links,
|
||||
geometry: {
|
||||
|
@ -135,18 +133,12 @@ export const tesseract = () => {
|
|||
const links = auto_detect_edges(nodes, 4);
|
||||
|
||||
return {
|
||||
name: 'tesseract',
|
||||
nodes: nodes,
|
||||
links: links,
|
||||
geometry: {
|
||||
node_size: 0.02,
|
||||
link_size: 0.02
|
||||
},
|
||||
base: {},
|
||||
options: [
|
||||
[ 'One inscribed 16-cell', {} ],
|
||||
[ 'Both inscribed 16-cells', {} ],
|
||||
],
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -211,12 +203,7 @@ export const cell24 = () => {
|
|||
geometry: {
|
||||
node_size: 0.02,
|
||||
link_size: 0.02
|
||||
},
|
||||
base: {},
|
||||
options: [
|
||||
[ 'One inscribed 16-cell', {} ],
|
||||
[ 'All inscribed 16-cells', {} ],
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -345,8 +332,6 @@ function make_120cell_vertices() {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
function label_nodes(nodes, ids, label) {
|
||||
nodes.filter((n) => ids.includes(n.id)).map((n) => n.label = label);
|
||||
}
|
||||
|
@ -354,8 +339,16 @@ function label_nodes(nodes, ids, label) {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function label_faces_120cell(nodes, faces, cfaces, label) {
|
||||
const ns = new Set();
|
||||
console.log(`label faces from ${cfaces}`);
|
||||
for( const fid of cfaces ) {
|
||||
const face = faces.filter((f)=> f.id === fid );
|
||||
if( face.length > 0 ) {
|
||||
|
@ -395,16 +388,6 @@ function label_120cell(nodes) {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
function layered_120cell(nodes, max_layer) {
|
||||
for (const cstr in CELL120.LAYERS ) {
|
||||
label_nodes(nodes, CELL120.LAYERS[cstr], Number(cstr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function link_labels(nodes, link) {
|
||||
const n1 = nodes.filter((n) => n.id === link.source);
|
||||
const n2 = nodes.filter((n) => n.id === link.target);
|
||||
|
@ -420,76 +403,44 @@ export const cell120 = () => {
|
|||
label_120cell(nodes);
|
||||
|
||||
return {
|
||||
name: '120-cell',
|
||||
nodes: nodes,
|
||||
links: links,
|
||||
geometry: {
|
||||
node_size: 0.02,
|
||||
link_size: 0.02
|
||||
},
|
||||
base: {},
|
||||
options: [
|
||||
[ 'One inscribed 600-cell', {} ],
|
||||
[ 'All inscribed 600-cells', {} ],
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export const cell120_layered = (max) => {
|
||||
const nodes = make_120cell_vertices();
|
||||
const links = auto_detect_edges(nodes, 4);
|
||||
|
||||
layered_120cell(nodes);
|
||||
|
||||
return {
|
||||
name: '120-cell layered',
|
||||
nodes: nodes,
|
||||
links: links,
|
||||
geometry: {
|
||||
node_size: 0.02,
|
||||
link_size: 0.02
|
||||
},
|
||||
options: [
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export const cell120_inscribed = () => {
|
||||
const cell120_some_inscribed = (ps) => {
|
||||
const nodes = make_120cell_vertices();
|
||||
const links = auto_detect_edges(nodes, 4);
|
||||
|
||||
label_120cell(nodes);
|
||||
|
||||
links.map((l) => l.label = 0);
|
||||
const all_links = links;
|
||||
all_links.map((l) => l.label = 0);
|
||||
|
||||
for( const p of [ 1, 2, 3, 4, 5 ]) {
|
||||
for( const p of ps) {
|
||||
const nodes600 = nodes.filter((n) => n.label === p);
|
||||
const links600 = auto_detect_edges(nodes600, 12);
|
||||
links600.map((l) => l.label = p);
|
||||
links.push(...links600);
|
||||
all_links.push(...links600);
|
||||
}
|
||||
|
||||
return {
|
||||
name: '120-cell inscribed',
|
||||
nodes: nodes,
|
||||
links: links,
|
||||
links: all_links,
|
||||
geometry: {
|
||||
node_size: 0.02,
|
||||
link_size: 0.02
|
||||
},
|
||||
options: [
|
||||
{ name: "none", links: [ 0 ]},
|
||||
{ name: "one", links: [ 0, 1 ] },
|
||||
{ name: "all", links: [ 0, 1, 2, 3, 4, 5 ] }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// export const cell120_inscribed = () => cell120_some_inscribed([1]);
|
||||
// export const cell120_all_inscribed = () => cell120_some_inscribed([1,2,3,4,5]);
|
||||
export const cell120_inscribed = () => cell120_some_inscribed([1]);
|
||||
export const cell120_all_inscribed = () => cell120_some_inscribed([1,2,3,4,5]);
|
||||
|
||||
|
||||
// Schoute's partition via https://arxiv.org/abs/1010.4353
|
||||
|
@ -784,4 +735,3 @@ const dodecahedron_some_inscribed = (ps) => {
|
|||
export const dodecahedron_inscribed = () => dodecahedron_some_inscribed([1]);
|
||||
export const dodecahedron_all_inscribed = () => dodecahedron_some_inscribed([1,2,3,4,5]);
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
// code for generating the 120-cell labels
|
||||
// has some overlap with permute - FIXME
|
||||
//testbed for playing with stuff in node repl
|
||||
|
||||
const THREE =require('three');
|
||||
|
||||
|
@ -134,7 +133,7 @@ function dist2(n1, n2) {
|
|||
return (n1.x - n2.x) ** 2 + (n1.y - n2.y) ** 2 + (n1.z - n2.z) ** 2 + (n1.w - n2.w) ** 2;
|
||||
}
|
||||
|
||||
export function auto_detect_edges(nodes, neighbours, debug=false) {
|
||||
function auto_detect_edges(nodes, neighbours, debug=false) {
|
||||
const seen = {};
|
||||
const nnodes = nodes.length;
|
||||
const links = [];
|
||||
|
@ -169,7 +168,7 @@ export function auto_detect_edges(nodes, neighbours, debug=false) {
|
|||
|
||||
|
||||
|
||||
export function make_120cell_vertices() {
|
||||
function make_120cell_vertices() {
|
||||
const phi = 0.5 * (1 + Math.sqrt(5));
|
||||
const r5 = Math.sqrt(5);
|
||||
const phi2 = phi * phi;
|
||||
|
@ -231,7 +230,7 @@ function fingerprint(ids) {
|
|||
|
||||
|
||||
|
||||
export function auto_120cell_faces(links) {
|
||||
function auto_120cell_faces(links) {
|
||||
const faces = [];
|
||||
const seen = {};
|
||||
let id = 1;
|
||||
|
@ -487,7 +486,7 @@ function colour_next_dodeca_maybe(nodes, links, faces, colours, dd, nextf, nextd
|
|||
const nextvs = dodecahedron_vertices(nextdd);
|
||||
// get the initial colour permutations from the existing labels;
|
||||
const p = [];
|
||||
for( let i = 0; i < 5; i ++ ) {
|
||||
for( i = 0; i < 5; i ++ ) {
|
||||
p[i] = colours[nextvs[i]];
|
||||
}
|
||||
const nlabels = colour_dodecahedron_from_face(nextdd, p);
|
||||
|
@ -669,12 +668,10 @@ function arctic(nodes, links, faces, startf, startn, max) {
|
|||
|
||||
|
||||
|
||||
// this is the final one that works for the whole 120-cell
|
||||
|
||||
export function label_120cell(nodes, links, faces, startf, startn) {
|
||||
function arctic_two(nodes, links, faces, startf, startn) {
|
||||
const pole = face_plus_to_dodecahedron(faces, startf, startn);
|
||||
const dds = [ pole ];
|
||||
const dd_families = { "0": [ pole ] }
|
||||
|
||||
const seen = {};
|
||||
seen[dd_fingerprint(pole)] = true;
|
||||
|
@ -682,15 +679,12 @@ export function label_120cell(nodes, links, faces, startf, startn) {
|
|||
const colours = colour_dodecahedron_from_face(dds[0], [ 1, 2, 3, 4, 5 ] );
|
||||
const vs = dodecahedron_vertices(dds[0]);
|
||||
|
||||
dd_families["1"] = [];
|
||||
|
||||
for( const face of pole ) {
|
||||
const [ nextdd, ncolours ] = follow_and_colour(
|
||||
nodes, links, faces, colours, pole, face
|
||||
);
|
||||
add_colours(colours, ncolours);
|
||||
dds.push(nextdd);
|
||||
dd_families["1"].push(nextdd);
|
||||
seen[dd_fingerprint(nextdd)] = true;
|
||||
}
|
||||
|
||||
|
@ -699,8 +693,6 @@ export function label_120cell(nodes, links, faces, startf, startn) {
|
|||
// 1, 12, 20, 12, 30 = 75
|
||||
// 0 1 13, 33, 45
|
||||
|
||||
dd_families["2"] = [];
|
||||
|
||||
for( const a of dds.slice(1, 13) ) {
|
||||
for( const i of [ 6, 7, 8, 9, 10 ] ) {
|
||||
const [ nextdd, ncolours ] = follow_and_colour(
|
||||
|
@ -710,7 +702,6 @@ export function label_120cell(nodes, links, faces, startf, startn) {
|
|||
if( !(fp in seen) ) {
|
||||
add_colours(colours, ncolours);
|
||||
dds.push(nextdd);
|
||||
dd_families["2"].push(nextdd);
|
||||
seen[fp] = true;
|
||||
}
|
||||
}
|
||||
|
@ -718,7 +709,6 @@ export function label_120cell(nodes, links, faces, startf, startn) {
|
|||
|
||||
// meridians = 45
|
||||
|
||||
dd_families["3"] = [];
|
||||
for( const a of dds.slice(1, 13) ) {
|
||||
const [ nextdd, ncolours ] = follow_and_colour(
|
||||
nodes, links, faces, colours, a, a[11]
|
||||
|
@ -727,16 +717,11 @@ export function label_120cell(nodes, links, faces, startf, startn) {
|
|||
if( !(fp in seen) ) {
|
||||
add_colours(colours, ncolours);
|
||||
dds.push(nextdd);
|
||||
dd_families["3"].push(nextdd);
|
||||
seen[fp] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// the 30 equatorials?
|
||||
|
||||
|
||||
dd_families["4"] = [];
|
||||
|
||||
for( const a of dds.slice(13, 46) ) {
|
||||
for( const i of [ 6, 7, 8, 9, 10 ] ) {
|
||||
const [ nextdd, ncolours ] = follow_and_colour(
|
||||
|
@ -745,15 +730,12 @@ export function label_120cell(nodes, links, faces, startf, startn) {
|
|||
const fp = dd_fingerprint(nextdd);
|
||||
if( !(fp in seen) ) {
|
||||
add_colours(colours, ncolours);
|
||||
dd_families["4"].push(nextdd);
|
||||
dds.push(nextdd);
|
||||
seen[fp] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dd_families["5"] = [];
|
||||
|
||||
for( const a of dds.slice(33, 76) ) {
|
||||
for( const i of [ 6, 7, 8, 9, 10 ] ) {
|
||||
const [ nextdd, ncolours ] = follow_and_colour(
|
||||
|
@ -763,18 +745,12 @@ export function label_120cell(nodes, links, faces, startf, startn) {
|
|||
if( !(fp in seen) ) {
|
||||
add_colours(colours, ncolours);
|
||||
dds.push(nextdd);
|
||||
dd_families["5"].push(nextdd);
|
||||
seen[fp] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// this should get the rest or explode!
|
||||
|
||||
dd_families["6"] = [];
|
||||
|
||||
|
||||
for( const a of dds ) {
|
||||
for( const i of [ 6, 7, 8, 9, 10 ] ) {
|
||||
const [ nextdd, ncolours ] = follow_and_colour(
|
||||
|
@ -783,7 +759,6 @@ export function label_120cell(nodes, links, faces, startf, startn) {
|
|||
const fp = dd_fingerprint(nextdd);
|
||||
if( !(fp in seen) ) {
|
||||
add_colours(colours, ncolours);
|
||||
dd_families["6"].push(nextdd);
|
||||
dds.push(nextdd);
|
||||
seen[fp] = true;
|
||||
}
|
||||
|
@ -797,7 +772,7 @@ export function label_120cell(nodes, links, faces, startf, startn) {
|
|||
}
|
||||
|
||||
|
||||
return { dodecahedra: dds, labels: labels, families: dd_families };
|
||||
return { dodecahedra: dds, labels: labels };
|
||||
}
|
||||
|
||||
|
||||
|
@ -840,6 +815,7 @@ function make_120cell_cells(faces) {
|
|||
for( const dd of dds ) {
|
||||
const fp = dd_fingerprint(dd);
|
||||
if( ! (fp in seen) ) {
|
||||
//console.log(`added dodeca ${fp}`);
|
||||
const d = {
|
||||
id: i,
|
||||
faces: dd,
|
||||
|
@ -951,44 +927,9 @@ function make_dodecahedron_vertices() {
|
|||
}
|
||||
|
||||
|
||||
// this one does the coherent indexing / partition into 600-cells
|
||||
|
||||
export function make_labelled_120cell() {
|
||||
const nodes = make_120cell_vertices();
|
||||
const links = auto_detect_edges(nodes, 4);
|
||||
const faces = auto_120cell_faces(links);
|
||||
|
||||
const labelled = label_120cell(nodes, links, faces, faces[0], 341);
|
||||
return labelled;
|
||||
}
|
||||
|
||||
export function make_layered_120cell() {
|
||||
const labelled = make_labelled_120cell();
|
||||
|
||||
// relabel by layer
|
||||
|
||||
const layer_dds = labelled["families"];
|
||||
const vertices_layers = {};
|
||||
const seen = {};
|
||||
|
||||
for( const layer of [ "0", "1", "2", "3", "4", "5", "6"] ) {
|
||||
vertices_layers[layer] = [];
|
||||
for( const dd of layer_dds[layer] ) {
|
||||
for( const face of dd ) {
|
||||
for( const n of face.nodes ) {
|
||||
if( !seen[n] ) {
|
||||
vertices_layers[layer].push(n);
|
||||
seen[n] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return vertices_layers;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// const nodes = make_120cell_vertices();
|
||||
// const links = auto_detect_edges(nodes, 4);
|
||||
// const faces = auto_120cell_faces(links);
|
||||
|
||||
|
||||
// console.log("Calculating 120-cell colours")
|
Loading…
Reference in New Issue