// cobweb3.scad // Parameters spiral_radius = 80; // Maximum radius of the spiral number_threads = 9; // number of radial threads spacing = 4; // Spacing between spiral loops thick = 0.75; // thickness of thread blob = 0.85; //joint thickness rf = 3; // add jitter to spiral spacing ra = 0.05; //angle jitter for radial threads rl = 1; // length jitter for radial threads ho = 0.2; // height offset for fdm printing in sequence /////////////////////// //generate radial threads // radial_lines must be in form of angle, length, not points x,y //o_lines= [for (a=[0:360/number_threads:359])[a,spiral_radius]]; o_lines= [for (a=[60:360/number_threads:419])[a,spiral_radius]]; //randomise angles and lengths radial_lines =[ for (i= o_lines)[i[0]*(1+rands(-ra,+ra,1)[0]),i[1]*(1+rands(0.5*rl,+rl,1)[0])]]; echo(radial_lines); spiral_spacing=spacing/(len(radial_lines)); module radial(){ // Draw radial lines and spiral for (i = [0:len(radial_lines)-1]) { angle= radial_lines[i][0]; length = radial_lines[i][1]; x = cos(angle) * length; y = sin(angle) * length; linear_extrude(thick) draw_line([0,0], [x,y]); // Radial line } } // Recursive module to generate a list of points on the spiral and draw lines between them module generate_points(i=0, p1=[0,0]) { if (i <= spiral_radius/spiral_spacing) { j = i % len(radial_lines); angle = radial_lines[j][0]; h= i+rands(-rf,+rf,1)[0]; x = cos(angle) * h * spiral_spacing; y = sin(angle) * h * spiral_spacing; p2 = [x, y]; linear_extrude(blob) translate([x,y]) circle(blob); if (i > 0) linear_extrude(thick) draw_line(p2, p1); // Line between points generate_points(i+1, p2); // Recursive call } } module draw_line(p1, p2) { // line is long thin square dp = p2 - p1; // Subtract p1 from p2 angle = atan2(dp[1], dp[0]); // Calculate the angle h = norm(dp); // Calculate the length translate(p1) // Translate the square to p1 rotate(a=angle, v=[0,0,1]) // Rotate the square translate([h/2,0]) // locate square on xaxis square([h, thick],true ); // Draw the square } module frame() linear_extrude(thick*2){ difference(){ square( spiral_radius*2.2,true); square((spiral_radius *2.2)-4*thick,true); } } use module all(){ color("black")frame(); color("silver")generate_points(); translate([0,0,ho]) // offset to let print as spiral (slicer requirement) color("silver")radial(); translate([20,23,thick-ho-ho]) rotate([0,0,-10]) flat(); // 'flat' spider } intersection(){ //trim to frame all(); translate([0,0,spiral_radius])cube(spiral_radius*2.2,true); }