1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-24 09:33:26 +01:00
dotSCAD/examples/spiral_polygons/spiral_polygon_fidget.scad

57 lines
1.4 KiB
OpenSCAD
Raw Normal View History

2021-06-01 06:43:33 +08:00
use <ellipse_extrude.scad>;
use <util/sum.scad>;
beginning_radius = 7.5;
2021-06-02 10:46:21 +08:00
fn = 4;
2021-06-02 10:51:22 +08:00
number_of_polygons = 10;
2021-06-01 06:43:33 +08:00
height = 30;
thickness = 1.5;
2021-06-02 10:46:21 +08:00
thickness_offset_factor = 1.5;
2021-06-01 06:43:33 +08:00
2021-06-02 10:46:21 +08:00
spiral_polygon_fidget(beginning_radius, fn, number_of_polygons, height, thickness, thickness_offset_factor);
2021-06-01 06:43:33 +08:00
2021-06-02 10:46:21 +08:00
module spiral_polygon_fidget(beginning_radius, fn, n, height, thickness, thickness_offset_factor) {
2021-06-01 06:43:33 +08:00
theta = 180 / fn;
2021-06-02 10:46:21 +08:00
thickness_offset = thickness * thickness_offset_factor;
2021-06-01 06:43:33 +08:00
y = beginning_radius - beginning_radius * cos(theta);
2021-06-02 10:46:21 +08:00
dr = y / cos(theta) + thickness_offset;
2021-06-01 06:43:33 +08:00
pw = pow((beginning_radius + dr) * sin(theta), 2);
function a(ri, ro, i) = acos((pow(ro, 2) + pow(ri, 2) - pw * pow(0.985, i)) / (2 * ro * ri));
module drawPolygon(r) {
circle(r, $fn = fn);
}
rs = [for(i = [0: n]) beginning_radius + i * dr];
//as = [for(i = [1: n]) a(rs[i - 1], rs[i], i) / 2];
2021-06-02 10:46:21 +08:00
s = [for(i = [1: n]) (rs[i] + thickness_offset) / rs[i - 1]];
2021-06-01 06:43:33 +08:00
half_height = height / 2;
module half() {
translate([0, 0, -half_height]) {
linear_extrude(half_height, scale = s[0])
difference() {
drawPolygon(beginning_radius);
drawPolygon(beginning_radius - thickness);
}
2021-06-02 10:51:22 +08:00
for(i = [1:n - 1]) {
2021-06-01 06:43:33 +08:00
//rotate(as[i] * 2)
linear_extrude(half_height, scale = s[i])
difference() {
drawPolygon(rs[i]);
drawPolygon(rs[i] - thickness);
}
}
}
}
half();
mirror([0, 0, 1])
half();
}