Added dodecahedron with compound of five cubes, refactored the
inscribed polytopes into one functionfeature-3d-shapes
parent
6e8cfa8763
commit
c8ce499b22
4
gui.js
4
gui.js
|
@ -7,7 +7,7 @@ const DEFAULTS = {
|
||||||
nodesize: 1.25,
|
nodesize: 1.25,
|
||||||
linkopacity: 0.5,
|
linkopacity: 0.5,
|
||||||
link2opacity: 0.5,
|
link2opacity: 0.5,
|
||||||
shape: '120-cell',
|
shape: 'five-cubes',
|
||||||
inscribed: false,
|
inscribed: false,
|
||||||
inscribe_all: false,
|
inscribe_all: false,
|
||||||
color: 0x3293a9,
|
color: 0x3293a9,
|
||||||
|
@ -45,7 +45,7 @@ class FourDGUI {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.gui.add(this.params, 'shape',
|
this.gui.add(this.params, 'shape',
|
||||||
[ 'dodecahedron', '5-cell', '16-cell', 'tesseract',
|
[ 'dodecahedron', 'five-cubes', '5-cell', '16-cell', 'tesseract',
|
||||||
'24-cell', '600-cell', '120-cell' ]
|
'24-cell', '600-cell', '120-cell' ]
|
||||||
).onChange(changeShape)
|
).onChange(changeShape)
|
||||||
this.gui.add(this.params, 'inscribed').onChange(changeShape);
|
this.gui.add(this.params, 'inscribed').onChange(changeShape);
|
||||||
|
|
3
main.js
3
main.js
|
@ -65,6 +65,7 @@ const STRUCTURES = {
|
||||||
'tesseract': POLYTOPES.tesseract(),
|
'tesseract': POLYTOPES.tesseract(),
|
||||||
'24-cell': POLYTOPES.cell24(),
|
'24-cell': POLYTOPES.cell24(),
|
||||||
'dodecahedron': POLYTOPES.dodecahedron(),
|
'dodecahedron': POLYTOPES.dodecahedron(),
|
||||||
|
'five-cubes': POLYTOPES.five_cubes(),
|
||||||
'120-cell': POLYTOPES.cell120(),
|
'120-cell': POLYTOPES.cell120(),
|
||||||
'600-cell': POLYTOPES.cell600(),
|
'600-cell': POLYTOPES.cell600(),
|
||||||
};
|
};
|
||||||
|
@ -75,6 +76,7 @@ const INSCRIBED = {
|
||||||
'120-cell': POLYTOPES.cell120_inscribed(),
|
'120-cell': POLYTOPES.cell120_inscribed(),
|
||||||
'600-cell': POLYTOPES.cell600_inscribed(),
|
'600-cell': POLYTOPES.cell600_inscribed(),
|
||||||
'dodecahedron': POLYTOPES.dodecahedron_inscribed(),
|
'dodecahedron': POLYTOPES.dodecahedron_inscribed(),
|
||||||
|
'five-cubes': POLYTOPES.five_cubes_inscribed(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const ALL_INSCRIBED = {
|
const ALL_INSCRIBED = {
|
||||||
|
@ -83,6 +85,7 @@ const ALL_INSCRIBED = {
|
||||||
'120-cell': POLYTOPES.cell120_all_inscribed(),
|
'120-cell': POLYTOPES.cell120_all_inscribed(),
|
||||||
'600-cell': POLYTOPES.cell600_all_inscribed(),
|
'600-cell': POLYTOPES.cell600_all_inscribed(),
|
||||||
'dodecahedron': POLYTOPES.dodecahedron_all_inscribed(),
|
'dodecahedron': POLYTOPES.dodecahedron_all_inscribed(),
|
||||||
|
'five-cubes': POLYTOPES.five_cubes_all_inscribed(),
|
||||||
}
|
}
|
||||||
|
|
||||||
let shape = false;
|
let shape = false;
|
||||||
|
|
111
polytopes.js
111
polytopes.js
|
@ -327,6 +327,8 @@ function make_120cell_vertices() {
|
||||||
].flat();
|
].flat();
|
||||||
index_nodes(nodes);
|
index_nodes(nodes);
|
||||||
scale_nodes(nodes, 0.5);
|
scale_nodes(nodes, 0.5);
|
||||||
|
label_120cell(nodes);
|
||||||
|
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,20 +415,18 @@ export const cell120 = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const cell120_some_inscribed = (ps) => {
|
const inscribed_polytope = (vertex_fn, edges, inscr_edges, parts) => {
|
||||||
const nodes = make_120cell_vertices();
|
const nodes = vertex_fn();
|
||||||
const links = auto_detect_edges(nodes, 4);
|
const links = auto_detect_edges(nodes, edges);
|
||||||
|
|
||||||
label_120cell(nodes);
|
|
||||||
|
|
||||||
const all_links = links;
|
const all_links = links;
|
||||||
all_links.map((l) => l.label = 0);
|
all_links.map((l) => l.label = 0);
|
||||||
|
|
||||||
for( const p of ps) {
|
for( const p of parts ) {
|
||||||
const nodes600 = nodes.filter((n) => n.label === p);
|
const nodes_in = nodes.filter((n) => n.label === p);
|
||||||
const links600 = auto_detect_edges(nodes600, 12);
|
const links_in = auto_detect_edges(nodes_in, inscr_edges);
|
||||||
links600.map((l) => l.label = p);
|
links_in.map((l) => l.label = p);
|
||||||
all_links.push(...links600);
|
all_links.push(...links_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -439,8 +439,13 @@ const cell120_some_inscribed = (ps) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = () => inscribed_polytope(
|
||||||
|
make_120cell_vertices, 4, 12, [1]
|
||||||
|
);
|
||||||
|
export const cell120_all_inscribed = () => inscribed_polytope(
|
||||||
|
make_120cell_vertices, 4, 12, [1,2,3,4,5]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Schoute's partition via https://arxiv.org/abs/1010.4353
|
// Schoute's partition via https://arxiv.org/abs/1010.4353
|
||||||
|
@ -628,36 +633,12 @@ export const cell600 = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const cell600_inscribed = () => inscribed_polytope(
|
||||||
|
make_600cell_vertices, 12, 8, [1]
|
||||||
const cell600_some_inscribed = (ps) => {
|
);
|
||||||
const nodes = make_600cell_vertices();
|
export const cell600_all_inscribed = () => inscribed_polytope(
|
||||||
const links = auto_detect_edges(nodes, 12);
|
make_600cell_vertices, 12, 8, [1,2,3,4,5]
|
||||||
|
);
|
||||||
const all_links = links;
|
|
||||||
all_links.map((l) => l.label = 0);
|
|
||||||
|
|
||||||
for( const p of ps) {
|
|
||||||
const nodes24 = nodes.filter((n) => n.label === p);
|
|
||||||
const links24 = auto_detect_edges(nodes24, 8);
|
|
||||||
links24.map((l) => l.label = p);
|
|
||||||
all_links.push(...links24);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
nodes: nodes,
|
|
||||||
links: all_links,
|
|
||||||
geometry: {
|
|
||||||
node_size: 0.02,
|
|
||||||
link_size: 0.02
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const cell600_inscribed = () => cell600_some_inscribed([1]);
|
|
||||||
export const cell600_all_inscribed = () => cell600_some_inscribed([1,2,3,4,5]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function make_dodecahedron_vertices() {
|
function make_dodecahedron_vertices() {
|
||||||
|
@ -708,18 +689,42 @@ export const dodecahedron = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const dodecahedron_some_inscribed = (ps) => {
|
export const dodecahedron_inscribed = () => inscribed_polytope(
|
||||||
|
make_dodecahedron_vertices, 3, 3, [1]
|
||||||
|
);
|
||||||
|
export const dodecahedron_all_inscribed = () => inscribed_polytope(
|
||||||
|
make_dodecahedron_vertices, 3, 3, [1,2,3,4,5]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// this can't be done with inscribed_polytope because each vertex
|
||||||
|
// belongs to two cubes
|
||||||
|
|
||||||
|
export const dodecahedron_five_cubes = (parts) => {
|
||||||
const nodes = make_dodecahedron_vertices();
|
const nodes = make_dodecahedron_vertices();
|
||||||
const links = auto_detect_edges(nodes, 3);
|
const links = auto_detect_edges(nodes, 3);
|
||||||
const all_links = links;
|
const all_links = links;
|
||||||
all_links.map((l) => l.label = 0);
|
all_links.map((l) => l.label = 0);
|
||||||
|
|
||||||
for( const p of ps) {
|
const CUBES = {
|
||||||
const tetran = nodes.filter((n) => n.label === p);
|
1: [ 1, 2, 3, 4, 5, 6, 7, 8 ],
|
||||||
const tetral = auto_detect_edges(tetran, 3);
|
2: [ 4, 5, 10, 11, 13, 16, 17, 20],
|
||||||
tetral.map((l) => l.label = p);
|
3: [ 2, 7, 9, 12, 13, 16, 18, 19],
|
||||||
all_links.push(...tetral);
|
4: [ 1, 8, 10, 11, 14, 15, 18, 19],
|
||||||
}
|
5: [ 3, 6, 9, 12, 14, 15, 17, 20]
|
||||||
|
};
|
||||||
|
if( parts.length > 0 ) {
|
||||||
|
// console.log(parts);
|
||||||
|
//console.log(parts.map(String));
|
||||||
|
//nodes.map((n) => n.label = 0);
|
||||||
|
for( const label of parts.map(String) ) {
|
||||||
|
console.log(`label = ${label}`);
|
||||||
|
const cube = nodes.filter((n) => CUBES[label].includes(n.id));
|
||||||
|
const cubel = auto_detect_edges(cube, 3);
|
||||||
|
cubel.map((l) => l.label = Number(label));
|
||||||
|
all_links.push(...cubel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
nodes: nodes,
|
nodes: nodes,
|
||||||
|
@ -727,11 +732,11 @@ const dodecahedron_some_inscribed = (ps) => {
|
||||||
geometry: {
|
geometry: {
|
||||||
node_size: 0.02,
|
node_size: 0.02,
|
||||||
link_size: 0.02
|
link_size: 0.02
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const five_cubes = () => dodecahedron_five_cubes([]);
|
||||||
export const dodecahedron_inscribed = () => dodecahedron_some_inscribed([1]);
|
export const five_cubes_inscribed = () => dodecahedron_five_cubes([1]);
|
||||||
export const dodecahedron_all_inscribed = () => dodecahedron_some_inscribed([1,2,3,4,5]);
|
export const five_cubes_all_inscribed = () => dodecahedron_five_cubes([1,2,3,4,5]);
|
||||||
|
|
||||||
|
|
36
testbed.js
36
testbed.js
|
@ -913,16 +913,32 @@ function make_dodecahedron_vertices() {
|
||||||
const phiinv = 1 / phi;
|
const phiinv = 1 / phi;
|
||||||
|
|
||||||
const nodes = [
|
const nodes = [
|
||||||
{ x: 1, y: 1, z: 1, w: 0 },
|
{ x: 1, y: 1, z: 1, w: 0, label: 4 },
|
||||||
{ x: 1, y: 1, z: -1, w: 0 },
|
{ x: 1, y: 1, z: -1, w: 0, label: 3 },
|
||||||
{ x: 1, y: -1, z: 1, w: 0 },
|
{ x: 1, y: -1, z: 1, w: 0, label: 3 },
|
||||||
{ x: 1, y: -1, z: -1, w: 0 },
|
{ x: 1, y: -1, z: -1, w: 0, label: 2 },
|
||||||
{ x: -1, y: 1, z: 1, w: 0 },
|
|
||||||
{ x: -1, y: 1, z: -1, w: 0 },
|
{ x: -1, y: 1, z: 1, w: 0, label: 3 },
|
||||||
{ x: -1, y: -1, z: 1, w: 0 },
|
{ x: -1, y: 1, z: -1, w: 0, label: 1 },
|
||||||
{ x: -1, y: -1, z: -1, w: 0 }
|
{ x: -1, y: -1, z: 1, w: 0, label: 5 },
|
||||||
].flat();
|
{ x: -1, y: -1, z: -1, w: 0, label: 3 },
|
||||||
scale_nodes(nodes, 0.5);
|
|
||||||
|
{ x: 0, y: phi, z: phiinv, w: 0, label: 5 },
|
||||||
|
{ x: 0, y: phi, z: -phiinv, w: 0 , label: 2 },
|
||||||
|
{ x: 0, y: -phi, z: phiinv, w: 0, label: 4 },
|
||||||
|
{ x: 0, y: -phi, z: -phiinv, w: 0 , label: 1 },
|
||||||
|
|
||||||
|
{ x: phiinv, y: 0, z: phi, w: 0 , label: 2},
|
||||||
|
{ x: phiinv, y: 0, z: -phi, w: 0 , label: 4},
|
||||||
|
{ x: -phiinv, y: 0, z: phi, w: 0 , label: 1},
|
||||||
|
{ x: -phiinv, y: 0, z: -phi, w: 0 , label: 5},
|
||||||
|
|
||||||
|
{ x: phi, y: phiinv, z:0, w: 0 , label: 1},
|
||||||
|
{ x: phi, y: -phiinv, z:0, w: 0 , label: 5},
|
||||||
|
{ x: -phi, y: phiinv, z:0, w: 0 , label: 4},
|
||||||
|
{ x: -phi, y: -phiinv, z:0, w: 0 , label: 2},
|
||||||
|
];
|
||||||
|
index_nodes(nodes);
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue