diff --git a/examples/spiral_polygons/fidget_polygon.scad b/examples/spiral_polygons/fidget_polygon.scad index 60d9ed71..b7d34cb5 100644 --- a/examples/spiral_polygons/fidget_polygon.scad +++ b/examples/spiral_polygons/fidget_polygon.scad @@ -1,3 +1,4 @@ +model = "POLYGON"; // [POLYGON, BASE, BOTH] beginning_radius = 7.5; fn = 4; number_of_polygons = 10; @@ -5,10 +6,11 @@ height = 20; thickness = 1.5; spacing = 0.5 * thickness; slope = 1.2; +base_height = height * 1.75; -fidget_polygon(beginning_radius, fn, number_of_polygons, height, thickness, spacing, slope); +fidget_polygon(model, beginning_radius, fn, number_of_polygons, height, thickness, spacing, slope, base_height); -module fidget_polygon(beginning_radius, fn, n, height, thickness, spacing, slope) { +module fidget_polygon(model, beginning_radius, fn, n, height, thickness, spacing, slope, base_height) { theta = 180 / fn; y = beginning_radius - beginning_radius * cos(theta); @@ -21,12 +23,12 @@ module fidget_polygon(beginning_radius, fn, n, height, thickness, spacing, slope circle(r, $fn = fn); } - rs = [for(i = [0: n]) beginning_radius + i * dr]; + rs = [for(i = [0: n + 1]) beginning_radius + i * dr]; //as = [for(i = [1: n]) a(rs[i - 1], rs[i], i) / 2]; half_height = height / 2; - s = [for(i = [1: n]) (rs[i] + slope * half_height) / rs[i]]; + s = [for(i = [1: n + 1]) (rs[i] + slope * half_height) / rs[i]]; module half() { translate([0, 0, -half_height]) { @@ -47,7 +49,63 @@ module fidget_polygon(beginning_radius, fn, n, height, thickness, spacing, slope } } - half(); - mirror([0, 0, 1]) - half(); + if(model == "POLYGON" || model == "BOTH") { + half(); + mirror([0, 0, 1]) + half(); + } + // base + + ring_thickness = thickness * 1.5; + module base_ring() { + translate([0, 0, -ring_thickness]) + difference() { + linear_extrude(ring_thickness, scale = 1.02) + offset(ring_thickness / 3, $fn = n) + drawPolygon(rs[n] * s[n] - thickness); + + linear_extrude(thickness * 4, center = true) + drawPolygon(rs[n] * s[n] - ring_thickness); + } + } + + if(model == "BASE" || model == "BOTH") { + color("white") { + // plate + translate([0, 0, -half_height]) + linear_extrude(half_height, scale = s[n]) + difference() { + drawPolygon(rs[n]); + drawPolygon(rs[n] - thickness); + } + + // ring + base_ring(); + mirror([0, 0, 1]) + base_ring(); + + translate([0, 0, -base_height + ring_thickness]) + mirror([0, 0, 1]) + scale([1, 1, 1.5]) + base_ring(); + + // stick + d = rs[n] * s[n]; + off_h = -base_height + ring_thickness; + a = 180 / fn; + stick_r = thickness * 1.75; + stick_h = base_height - ring_thickness; + for(i = [0:fn - 1]) { + rotate(360 / fn * i) + translate([d, 0, off_h]) + rotate(a) { + linear_extrude(stick_h) + circle(stick_r, $fn = fn); + translate([0, 0, stick_h]) + linear_extrude(ring_thickness, scale = 0.75) + circle(stick_r, $fn = fn); + } + } + } + } } \ No newline at end of file