Added layered 120-cell

feature-120-cell-layers
Mike Lynch 2023-11-01 12:52:59 +11:00
parent 6d9610a1c6
commit 7323935a1f
2 changed files with 32 additions and 5 deletions

View File

@ -121,8 +121,12 @@ function changeShape() {
function setVisibility(option_name) {
const option = structure.options.filter((o) => o.name === option_name);
node_show = option[0].nodes;
link_show = option[0].links;
if( option.length ) {
node_show = option[0].nodes;
link_show = option[0].links;
} else {
console.log(`Error: option '${option_name}' not found`);
}
}

View File

@ -392,6 +392,8 @@ function link_labels(nodes, link) {
}
// version of the 120-cell where nodes are partitioned by
// layer and the links follow that
export const cell120_layered = (max) => {
const nodes = make_120cell_vertices();
@ -399,6 +401,27 @@ export const cell120_layered = (max) => {
layered_120cell(nodes);
links.map((l) => {
const labels = link_labels(nodes, l);
if( labels[0] >= labels[1] ) {
l.label = labels[0];
} else {
l.label = labels[1];
}
});
const options = [];
const layers = [];
for( const i of [ 0, 1, 2, 3, 4, 5, 6 ] ) {
layers.push(i);
options.push({
name: "Layer " + String(i),
links: [...layers],
nodes: [...layers]
})
}
return {
name: '120-cell layered',
nodes: nodes,
@ -407,8 +430,7 @@ export const cell120_layered = (max) => {
node_size: 0.02,
link_size: 0.02
},
options: [
]
options: options
}
}
@ -720,6 +742,7 @@ export const build_all = () => {
tesseract(),
cell24(),
cell600(),
cell120_inscribed()
cell120_inscribed(),
cell120_layered()
];
}