Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5362

Other programming languages • Re: JavaScript graph library, for embedding and drawing planar graphs in 2D and/or sphere surface

$
0
0
The last piece missing for implementation of "edge3()" is just move to the right position and use OpenSCAD's rotate_extrude()
Image
with the apropriate angle less than 360° ...
I tried and tried to get it right in my existing sphere embedding script, but was not able to rotate so that the line through origin and grey vertices (black) center vertex (the point on plane with minimal distance to origin) has plane going through all grey vertices. So I worked the other way around, started with simple extruded circle of less than 360° angle, displayed a vertex at its center, did draw line from origin to center, converted cartesian coordinate to spherical two angle coordinate, and finally got it right. For a nice demo I added variable $t for OpenSCAD animation. Find complete OpenSCAD script below:
Peek_2024-09-06_01-35.gif

Code:

module edge(v,w) {    w = w - v;    translate(v)    rotate([0, acos(w[2]/norm(w)), atan2(w[1], w[0])])    cylinder(norm(w),0.1,0.1);}l=5;p = [l*sin($t*360),l*cos($t*360),2*sin($t*7*360)];pol = [atan2(p[1],p[0]), acos(p[2]/l)];

Code:

edge([0,0,0],p);translate(p)  sphere(0.2,$fn=36);translate(p)rotate([0,pol[1],pol[0]])rotate_extrude(angle=330, convexity = 10, $fn = 100)translate([1, 0, 0])circle(r = 0.1, $fn = 100);

Statistics: Posted by HermannSW — Thu Sep 05, 2024 11:50 pm



Viewing all articles
Browse latest Browse all 5362

Trending Articles