//////////////////////////////////////// // VARIABLES radius = 20; // sphere radius pi = 3.14159; // pi ¯\_(ツ)_/¯ theta = 0; alpha = 0; // 3D line parameters smooth = 10; // line smoothing - WARNING: increasing this value too much causes the compilation to take a long time. line_w = 1.5; // line width // Sphere position x0 = 0; y0 = 0; z0 = 0; h_n = 8; // horizontal lines //////////////////////////////////////// // FUNCTIONS function MySphere(radius, theta, alpha) = let( x = x0 + radius * sin(theta) * cos(alpha), y = y0 + radius * sin(theta) * sin(alpha), z = z0 + radius * cos(theta) ) [x, y, z]; function getPoints(d) = [ for (i = [0:2:180]) MySphere(radius, i, i*d) ]; //////////////////////////////////////// // MODULES module line(start, end){ hull() { translate(start) sphere(r=line_w, $fn=smooth); translate(end) sphere(r=line_w, $fn=smooth); } } module poly3Dline(points, index){ if(index < len(points)){ line(points[index - 1], points[index]); poly3Dline(points, index + 1); } } //////////////////////////////////////// // TEST //poly3Dline(getPoints(), 1); //////////////////////////////////////// // MAIN for(i = [0:h_n]) { rotate(45*i) poly3Dline(getPoints(1), 1); } for(i = [0:h_n]) { rotate(45*i) poly3Dline(getPoints(-1), 1); }