From 89ec4df5838f6d0da585e6402c7adade188f071b Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 16 Jun 2021 10:17:49 +0800 Subject: [PATCH] add base --- examples/spiral_polygons/fidget_star.scad | 76 +++++++++++++++++++++-- 1 file changed, 70 insertions(+), 6 deletions(-) diff --git a/examples/spiral_polygons/fidget_star.scad b/examples/spiral_polygons/fidget_star.scad index 5c43aae5..0f2fbc85 100644 --- a/examples/spiral_polygons/fidget_star.scad +++ b/examples/spiral_polygons/fidget_star.scad @@ -1,13 +1,15 @@ use ; +model = "STAR"; // [STAR, BASE, BOTH] r1 = 12; r2 = 9.5; n = 6; -number_of_stars = 10; +number_of_stars = 8; height = 20; thickness = 1; spacing = thickness; slope = 0.35; +base_height = height * 1.75; /* r1 = 12; @@ -20,9 +22,9 @@ spacing = thickness; slope = 0.26; */ -fidget_star(r1, r2, n, number_of_stars, height, thickness, spacing, slope); +fidget_star(model, r1, r2, n, number_of_stars, height, thickness, spacing, slope, base_height); -module fidget_star(r1, r2, n, number_of_stars, height, thickness, spacing, slope) { +module fidget_star(model, r1, r2, n, number_of_stars, height, thickness, spacing, slope, base_height) { theta = 180 / n; y = r2 - r2 * cos(theta); @@ -62,7 +64,69 @@ module fidget_star(r1, r2, n, number_of_stars, height, thickness, spacing, slope } } - half(); - mirror([0, 0, 1]) - half(); + + if(model == "STAR" || 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) + offset(delta = -thickness) + star(rs2[number_of_stars] * s[number_of_stars] * r_ratio, rs2[number_of_stars] * s[number_of_stars]); + //star(rs[n] * s[n] - thickness); + + linear_extrude(thickness * 4, center = true) + offset(delta = -ring_thickness) + star(rs2[number_of_stars] * s[number_of_stars] * r_ratio, rs2[number_of_stars] * s[number_of_stars]); + //star(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[number_of_stars]) + difference() { + star(rs1[number_of_stars], rs2[number_of_stars]); + offset(delta = -thickness) + star(rs1[number_of_stars], rs2[number_of_stars]); + } + + // 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 = rs1[number_of_stars] * s[number_of_stars]; + off_h = -base_height + ring_thickness; + a = 180 / n; + stick_r = thickness * 1.75; + stick_h = base_height - ring_thickness; + for(i = [0:n - 1]) { + rotate(360 / n * i) + translate([d, 0, off_h]) + rotate(a) { + linear_extrude(stick_h) + circle(stick_r, $fn = n); + translate([0, 0, stick_h]) + linear_extrude(ring_thickness, scale = 0.75) + circle(stick_r, $fn = n); + } + } + } + } } \ No newline at end of file