Added the rest of the regular 3-d polyhedra
parent
78ebb381ee
commit
f79a90e0d9
147
polytopes.js
147
polytopes.js
|
@ -755,8 +755,155 @@ export const dodecahedron = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const tetrahedron = () => {
|
||||||
|
const r2 = Math.sqrt(2);
|
||||||
|
const r3 = Math.sqrt(3);
|
||||||
|
return {
|
||||||
|
name: 'Tetrahedron',
|
||||||
|
nodes: [
|
||||||
|
{id:1, label: 1, x: 2 * r2 / 3, y: 0, z: -1/3, w: 0 },
|
||||||
|
{id:2, label: 2, x: -r2 / 3, y: r2 / r3, z: -1/3, w: 0 },
|
||||||
|
{id:3, label: 3, x: -r2 / 3, y: -r2 / r3, z: -1/3, w: 0 },
|
||||||
|
{id:4, label: 4, x: 0, y: 0, z: 1, w: 0 },
|
||||||
|
],
|
||||||
|
links: [
|
||||||
|
{ id:1, source:1, target: 2},
|
||||||
|
{ id:2, source:1, target: 3},
|
||||||
|
{ id:3, source:1, target: 4},
|
||||||
|
{ id:4, source:2, target: 3},
|
||||||
|
{ id:5, source:2, target: 4},
|
||||||
|
{ id:6, source:3, target: 4},
|
||||||
|
],
|
||||||
|
geometry: {
|
||||||
|
node_size: 0.02,
|
||||||
|
link_size: 0.02
|
||||||
|
},
|
||||||
|
options: [ { name: '--' }],
|
||||||
|
description: `The simplest three-dimensional polytope, consisting of four triangles joined at six edges. The 5-cell is its four-dimensional analogue.`,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const octahedron = () => {
|
||||||
|
const nodes = [
|
||||||
|
{id: 1, label: 1, x: 1, y: 0, z: 0, w: 0},
|
||||||
|
{id: 2, label: 1, x: -1, y: 0, z: 0, w: 0},
|
||||||
|
{id: 3, label: 2, x: 0, y: 1, z: 0, w: 0},
|
||||||
|
{id: 4, label: 2, x: 0, y: -1, z: 0, w: 0},
|
||||||
|
{id: 5, label: 3, x: 0, y: 0, z: 1, w: 0},
|
||||||
|
{id: 6, label: 3, x: 0, y: 0, z: -1, w: 0},
|
||||||
|
];
|
||||||
|
const links = [
|
||||||
|
{id:1, source: 1, target: 3},
|
||||||
|
{id:2, source: 1, target: 4},
|
||||||
|
{id:3, source: 1, target: 5},
|
||||||
|
{id:4, source: 1, target: 6},
|
||||||
|
{id:5, source: 2, target: 3},
|
||||||
|
{id:6, source: 2, target: 4},
|
||||||
|
{id:7, source: 2, target: 5},
|
||||||
|
{id:8, source: 2, target: 6},
|
||||||
|
{id:9, source: 3, target: 5},
|
||||||
|
{id:10, source: 3, target: 6},
|
||||||
|
{id:11, source: 4, target: 5},
|
||||||
|
{id:12, source: 4, target: 6},
|
||||||
|
]
|
||||||
|
links.map((l) => { l.label = 0 });
|
||||||
|
return {
|
||||||
|
name: 'Octahedron',
|
||||||
|
nodes: nodes,
|
||||||
|
links: links,
|
||||||
|
geometry: {
|
||||||
|
node_size: 0.02,
|
||||||
|
link_size: 0.02
|
||||||
|
},
|
||||||
|
options: [ { name: '--' }],
|
||||||
|
description: `The three-dimensional cross-polytope, the 16-cell is its four-dimensional analogue.`,
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export const cube = () => {
|
||||||
|
const nodes = [
|
||||||
|
{id: 1, label: 1, x: 1, y: 1, z: 1, w: 0},
|
||||||
|
{id: 2, label: 2, x: -1, y: 1, z: 1, w: 0},
|
||||||
|
{id: 3, label: 2, x: 1, y: -1, z: 1, w: 0},
|
||||||
|
{id: 4, label: 1, x: -1, y: -1, z: 1, w: 0},
|
||||||
|
{id: 5, label: 2, x: 1, y: 1, z: -1, w: 0},
|
||||||
|
{id: 6, label: 1, x: -1, y: 1, z: -1, w: 0},
|
||||||
|
{id: 7, label: 1, x: 1, y: -1, z: -1, w: 0},
|
||||||
|
{id: 8, label: 2, x: -1, y: -1, z: -1, w: 0},
|
||||||
|
];
|
||||||
|
scale_nodes(nodes, 1/Math.sqrt(3));
|
||||||
|
const links = auto_detect_edges(nodes, 3);
|
||||||
|
links.map((l) => { l.label = 0 });
|
||||||
|
return {
|
||||||
|
name: 'Cube',
|
||||||
|
nodes: nodes,
|
||||||
|
links: links,
|
||||||
|
geometry: {
|
||||||
|
node_size: 0.02,
|
||||||
|
link_size: 0.02
|
||||||
|
},
|
||||||
|
options: [ { name: '--' }],
|
||||||
|
description: `The three-dimensional measure polytope, the tesseract is its four-dimensional analogue.`,
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function make_icosahedron_vertices() {
|
||||||
|
const phi = 0.5 * (1 + Math.sqrt(5));
|
||||||
|
|
||||||
|
const nodes = [
|
||||||
|
{ x: 0, y: 1, z: phi, w: 0, label: 1 },
|
||||||
|
{ x: 0, y: -1, z: phi, w: 0, label: 1 },
|
||||||
|
{ x: 0, y: 1, z: -phi, w: 0, label: 1 },
|
||||||
|
{ x: 0, y: -1, z: -phi, w: 0, label: 1 },
|
||||||
|
{ x: 1, y: phi, z: 0, w: 0, label: 2 },
|
||||||
|
{ x: -1, y: phi, z: 0, w: 0, label: 2 },
|
||||||
|
{ x: 1, y: -phi, z: 0, w: 0, label: 2 },
|
||||||
|
{ x: -1, y: -phi, z: 0, w: 0, label: 2 },
|
||||||
|
{ x: phi, y: 0, z: 1, w: 0, label: 3},
|
||||||
|
{ x: phi, y: 0, z: -1, w: 0, label: 3},
|
||||||
|
{ x: -phi, y: 0, z: 1, w: 0, label: 3},
|
||||||
|
{ x: -phi, y: 0, z: -1, w: 0, label: 3},
|
||||||
|
];
|
||||||
|
|
||||||
|
scale_nodes(nodes, 1/Math.sqrt((5 + Math.sqrt(5)) / 2));
|
||||||
|
index_nodes(nodes);
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const icosahedron = () => {
|
||||||
|
const nodes = make_icosahedron_vertices();
|
||||||
|
const links = auto_detect_edges(nodes, 5);
|
||||||
|
links.map((l) => l.label = 0);
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: 'Icosahedron',
|
||||||
|
nodes: nodes,
|
||||||
|
links: links,
|
||||||
|
geometry: {
|
||||||
|
node_size: 0.02,
|
||||||
|
link_size: 0.02
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{ name: "--"},
|
||||||
|
],
|
||||||
|
description: `The icosahedron is a twenty-sided polyhedron and is dual to the dodecahedron. Its four-dimensional analogue is the 600-cell.`
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const build_all = () => {
|
export const build_all = () => {
|
||||||
return [
|
return [
|
||||||
|
tetrahedron(),
|
||||||
|
octahedron(),
|
||||||
|
cube(),
|
||||||
|
icosahedron(),
|
||||||
dodecahedron(),
|
dodecahedron(),
|
||||||
cell5(),
|
cell5(),
|
||||||
cell16(),
|
cell16(),
|
||||||
|
|
Loading…
Reference in New Issue