From 2992f4ab66b66e8eb9c73e0107d40766216bc194 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Mon, 31 Jul 2023 17:23:57 +1000 Subject: [PATCH] Added debug flag to edge detector --- polytopes.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/polytopes.js b/polytopes.js index 326445a..8dbbfac 100644 --- a/polytopes.js +++ b/polytopes.js @@ -17,7 +17,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; } -function auto_detect_edges(nodes, neighbours) { +function auto_detect_edges(nodes, neighbours, debug=false) { const seen = {}; const nnodes = nodes.length; const links = []; @@ -29,6 +29,10 @@ function auto_detect_edges(nodes, neighbours) { } d2.sort((a, b) => a.d2 - b.d2); const closest = d2.slice(1, neighbours + 1); + if( debug ) { + console.log(`closest = ${closest.length}`); + console.log(closest); + } for( const e of closest ) { const ids = [ n1.id, e.id ]; ids.sort(); @@ -40,6 +44,9 @@ function auto_detect_edges(nodes, neighbours) { } } } + if( debug ) { + console.log(`Found ${links.length} edges`) + } return links; } @@ -179,7 +186,7 @@ function make_600cell_vertices() { export const cell600 = () => { const nodes = make_600cell_vertices(); - const links = auto_detect_edges(nodes, 12); + const links = auto_detect_edges(nodes, 12, true); return { nodes: nodes, links: links,