600-cell hard-coded indexing and coloured nodes
parent
0fdf8a40e4
commit
82195b717f
|
@ -1,8 +1,10 @@
|
|||
import ColorScheme from 'color-scheme';
|
||||
|
||||
export const get_colours = () => {
|
||||
var scheme = new ColorScheme;
|
||||
scheme.from_hue(21).scheme('triade').variation('soft');
|
||||
export const get_colours = (basis) => {
|
||||
const scheme = new ColorScheme;
|
||||
const hexbasis = basis.toString(16).padStart(6, "0");
|
||||
scheme.from_hex(hexbasis).scheme('analogic').variation('hard').distance(0.1);
|
||||
console.log(scheme.colors());
|
||||
return scheme.colors().map((cs) => parseInt('0x' + cs));
|
||||
}
|
||||
|
||||
|
|
12
main.js
12
main.js
|
@ -31,8 +31,8 @@ document.body.appendChild( renderer.domElement );
|
|||
|
||||
scene.background = new THREE.Color(0x808080);
|
||||
const material = new THREE.MeshStandardMaterial({ color: 0x3293a9 });
|
||||
const node_colours = get_colours();
|
||||
|
||||
const node_colours = get_colours(0x3293a9);
|
||||
console.log(node_colours);
|
||||
const node_ms = node_colours.map((c) => new THREE.MeshStandardMaterial({color: c}));
|
||||
|
||||
const link_ms = [ material ];
|
||||
|
@ -63,7 +63,13 @@ function createShape(name) {
|
|||
|
||||
const gui = new FourDGUI(
|
||||
createShape,
|
||||
(c) => { material.color = new THREE.Color(c) },
|
||||
(c) => {
|
||||
const nc = get_colours(c);
|
||||
for( let i = 0; i < node_ms.length; i++ ) {
|
||||
node_ms[i].color = new THREE.Color(nc[i]);
|
||||
}
|
||||
material.color = new THREE.Color(c);
|
||||
},
|
||||
(c) => { scene.background = new THREE.Color(c) },
|
||||
);
|
||||
|
||||
|
|
47
polytopes.js
47
polytopes.js
|
@ -223,7 +223,7 @@ const partition600 = {
|
|||
"1,0,-k,t": 3,
|
||||
"k,t,1,0": 3,
|
||||
|
||||
"t,0,-1,k": 4,
|
||||
"t,0,-1,-k": 4,
|
||||
"0,t,k,-1": 4,
|
||||
"1,-k,t,0": 4,
|
||||
"k,1,0,t": 4,
|
||||
|
@ -252,9 +252,35 @@ const partition600 = {
|
|||
|
||||
|
||||
|
||||
// permute unique indices ->
|
||||
// use these to label nodes ->
|
||||
// assign actual values to indices ->
|
||||
function partition_coord(i, coords, invert) {
|
||||
const j = invert ? -i : i;
|
||||
if( j >= 0 ) {
|
||||
return coords[j];
|
||||
}
|
||||
return "-" + coords[-j];
|
||||
}
|
||||
|
||||
function partition_fingerprint(n, coords, invert) {
|
||||
const p = ['x','y','z','w'].map((a) => partition_coord(n[a], coords, invert));
|
||||
const fp = p.join(',');
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
||||
function label_vertex(n, coords, partition) {
|
||||
const fp = partition_fingerprint(n, coords, false);
|
||||
if( fp in partition ) {
|
||||
return partition[fp];
|
||||
} else {
|
||||
const ifp = partition_fingerprint(n, coords, true);
|
||||
if( ifp in partition ) {
|
||||
return partition[ifp];
|
||||
}
|
||||
console.log(`Map for ${fp} ${ifp} not found`);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function map_coord(i, coords, values) {
|
||||
if( i >= 0 ) {
|
||||
|
@ -282,20 +308,23 @@ function make_600cell_vertices() {
|
|||
};
|
||||
|
||||
const nodes = [
|
||||
PERMUTE.coordinates([0, 0, 0, 2], ),
|
||||
PERMUTE.coordinates([0, 0, 0, 2], 0),
|
||||
PERMUTE.coordinates([1, 1, 1, 1], 0),
|
||||
|
||||
PERMUTE.coordinates([3, 1, 4, 0], 1, true)
|
||||
PERMUTE.coordinates([3, 1, 4, 0], 0, true)
|
||||
].flat();
|
||||
|
||||
for( const n of nodes ) {
|
||||
n.label = label_vertex(n, coords, partition600);
|
||||
}
|
||||
|
||||
for( const n of nodes ) {
|
||||
for( const a of [ 'x', 'y', 'z', 'w'] ) {
|
||||
n[a] = map_coord(n[a], coords, values);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
index_nodes(nodes);
|
||||
//const groups = partition_nodes_by_distance(nodes, 2);
|
||||
scale_nodes(nodes, 0.75);
|
||||
return nodes;
|
||||
}
|
||||
|
@ -311,7 +340,7 @@ export const cell600 = () => {
|
|||
links: links,
|
||||
geometry: {
|
||||
node_size: 0.08,
|
||||
link_size: 0.02
|
||||
link_size: 0.01
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue