Medial graph
Navigation
2d scroll → move
middle click + mouse → move
ctrl+scroll → zoom
ctrl + middle click + mouse → zoom
Edition
ctrl + left click → new node / twist edge
ctrl + right click → remove node / twist edge
TODO
graphics : default knot curves to be tuned and controled with angle between edges
graphics : manual control to make the knot more readable
feature : colorize connex components
feature : no-twist edge
feature : twist edge sign (positive or negative) + knot orientation
feature : swap edge type (twist+ or twist- or twist0)
NOTE
The graph should be planar. But the algorithm seems not to be too crazy in that case (to be inspected)
HELP
open up the console (ctrl+shift+j on chromium) and generate your graphs and knots !
G // this is the graph
G.clearAll() // this will remove everything we have now.
let n1 = G.addNode([0,2]) // add a node at [0,2] on screen
let n2 = G.addNode([0,1]) // add a node at [0,1] on screen
G.addEdge(n1,n2) // add an edges between the two previous nodes
// there also is an useful function that adds vectors
// as we can't overload operator+ in js
let v = vec2add([0,1],[-1,-1])
// here is an example of it's usage
let generate_mesh1 = (k_max,position) => {
n[0] = G.addNode(vec2add(position,[0,0]));
for( let k=1 ; k < k_max ; k++ ) {
let θ = 2*π*k/k_max + π/2
n[k] = G.addNode(vec2add(position,[cos(θ),sin(θ)]));
}
for( let k=1 ; k < k_max ; k++ ) {
G.addEdge(n[0],n[k]);
}
for( let k=1 ; k < k_max-1 ; k++ ) {
G.addEdge(n[k],n[k+1]);
}
}
generate_mesh1(7,[0,-1])