https://github.com/Hermann-SW/planar_graph_playground

Libraries (undirected graph, ...) are implemented in JavaScript/NodeJS, Python and C++.

`forall_edges(G, function(e) { ... });`

is the JavaScript way of iterating over all edges of undirected graph G, `forall_edges(G, lambda e: ...)`

the Python way, and `forall_edges(G, [&G, &visited, &pftv](edge g) { ... });`

the C++ way.
First (2D) graph output was done with SVG in browser, then mostly as PostScript. Online demo for displaying fullerenes:

https://hermann-sw.github.io/planar_graph_playground/

Lately I created OpenSCAD output for planar embedding onto sphere (every planar graph can be embedded onto sphere, with non-crossing great circle arcs as edges, because of a bijection of plane and unit sphere minus north pole). Has lots of spherical computations inside and looks nice (embedding of C60 or "football" fullerene, 20 hexagons and 12 pentagons on 60 vertices):

https://forums.raspberrypi.com/viewtopic.php?t=333342&start=75#p2026845

Two days ago I overcame problems I had with getting JSCAD packages/web running locally, and since then I am on the way to produce same output using JSCAD. Sofar "vertex()", straight line "edge()" and great circle arc "edge2()" have been ported successfully to JSCAD, documented in further postings in that thread:

You can play live with C20 fullerene embedding in your browser:

https://www.openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/JSCAD.vertex_edge2.js

https://forums.raspberrypi.com/viewtopic.php?p=2030546#p2030546

Until now I played with C20 hand edited for JSCAD, this is newly created C60 fullerene with 60 vertices and 90 edges:

https://www.openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/JSCAD.C60_vtype.js

More vertices and edges than for C20, but design regeneration still done in less than 10 seconds on Intel it Linux Chrome!

`12*3*2=72`

`sp_tria2()`

calls, ...), details here:https://forums.raspberrypi.com/viewtopic.php?p=2029576#p2029576

https://www.openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/JSCAD.C20_params.js

https://www.openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/JSCAD.vertex_half.js

Green vertices 1, 2, 15 and 16 are forced as "half" vertices, that is a cube of right size gets subtracted from inside. Subtraction can be seen for vertex 1 at "look_inside" hole border. Vertex 2, 15 and 16 cannot be seen on inside anymore, unlike the other vertices with default "half=false":

```
...
vertex(0, [1,0,0])
,vertex(1, [0,1,0], true)
,vertex(2, [0,1,0], true)
...
,vertex(15, [0,1,0], true)
,vertex(16, [0,1,0], true)
...
```

]]>https://www.openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/JSCAD.vtxt.js ]]>

https://openjscad.nodebb.com/topic/378/problem-with-subtract-ing-hull-is-this-a-bug/3?_=1660487451987

... now spherical triangle works. I called it three times to fill one spherical pentagon:

```
,sp_tria(2,1,15)
,sp_tria(2,15,16)
,sp_tria(2,16,3)
...
```

You can see spherical gray polygon from outside, and nothing of spherical polygon breaks into white sphere difference on the inside:

Click for view+rotate+zoom, design regeneration takes less than 3 seconds on Intel i7 Chrome

(normally I use chromium-browser on Raspberry Pi OS, will test that in 2 weeks):

https://www.openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/JSCAD.spherical_polygon.js

Clicking "Enable Auoto-zoom" and "Enable Auto-rotate" results in nice animation ...

P.S:

Next step is to port "vtxt()" for adding text labels to vertex sphere, and "half()" for subtracting cube from inner side of vertex sphere, avoiding vertex to shine through to inside for 3Dprinting later.

After that is done, I will make "node.tetra.js" create JSCAD output as alternative to sofar OpenSCAD output. Creating C60 with 12 spherical pentagons JSCAD file and measuring design regeneration time for it will answer whether JSCAD is usable for great circle arc edge embedding of planar graphs onto sphere: 12 spherical pentagons is 12*3=36 spherical triangles, is 72 "sp_tria2()" and 36 differences with "hull()" of 6 points (mini cubes) ...

@Hermann-SW WOW! Very nice!

I'm very impressed with the speed of the algorithms! I was expecting to wait for minutes before viewing. But the design was viewable almost immediately!

Do you think that any 3D shape can be 'fitted' to a sphere? How about to a cylinder?

Sure, just calculate the correct (3D) coordinates and place whatever you like on sphere. For cylinder just 3D coordinate determination will be different [(theta, phi) polar coordinates for sphere, (h, phi) for cylinder coordinate at height h].

Here I placed text onto the vertex spheres on the sphere for debugging:

https://forums.raspberrypi.com/viewtopic.php?t=333342&start=50#p2023738

I'm very impressed with the speed of the algorithms! I was expecting to wait for minutes before viewing. But the design was viewable almost immediately!

Do you think that any 3D shape can be 'fitted' to a sphere? How about to a cylinder?

]]>https://forums.raspberrypi.com/viewtopic.php?p=2028520#p2028520

Learned that number of segments for white sphere is a problem when "subtract()" another sphere with radius reduced by 0.1. 180 segments was no problem for OpenSCAD, for JSCAD I did set parameter default to 30.

]]>