1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-29 17:30:11 +02:00
This commit is contained in:
Justin Lin
2021-06-03 09:21:04 +08:00
parent 2c02c0ff59
commit 6330473ea7

View File

@@ -0,0 +1,54 @@
beginning_radius = 7.5;
fn = 4;
number_of_polygons = 10;
height = 20;
thickness = 1.5;
thickness_offset_factor = 1.5;
fidget_polygon(beginning_radius, fn, number_of_polygons, height, thickness, thickness_offset_factor);
module fidget_polygon(beginning_radius, fn, n, height, thickness, thickness_offset_factor) {
theta = 180 / fn;
thickness_offset = thickness * thickness_offset_factor;
y = beginning_radius - beginning_radius * cos(theta);
dr = y / cos(theta) + thickness_offset;
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];
s = [for(i = [1: n]) (rs[i] + thickness_offset) / rs[i - 1]];
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);
}
for(i = [1:n - 1]) {
//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();
}