1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-18 20:41:18 +02:00

change dir

This commit is contained in:
Justin Lin
2021-03-24 10:52:47 +08:00
parent 98bbc03988
commit bef4ec42c1
2 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
use <shape_circle.scad>;
use <hull_polyline2d.scad>;
use <util/sum.scad>;
beginning_radius = 10;
line_width = 2;
fn = 3;
number_of_polygons = 10;
height = 2;
linear_extrude(height)
spiral_polygons(beginning_radius, line_width, fn, number_of_polygons);
module spiral_polygons(beginning_radius, line_width, fn, n) {
theta = 180 / fn;
y = beginning_radius - beginning_radius * cos(theta);
dr = y / cos(theta);
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) {
pts = shape_circle(radius = r, $fn = fn);
hull_polyline2d(concat(pts, [pts[0]]), width = line_width, $fn = 12);
}
rs = [for(i = [0: n - 1]) beginning_radius + i * dr];
as = [for(i = [1: n - 1]) a(rs[i - 1], rs[i], i) / 2];
rotate(-as[0])
drawPolygon(beginning_radius);
for(i = [1:n - 1]) {
rotate(sum([for(j = [0:i - 1]) as[j]]))
drawPolygon(rs[i]);
}
}

View File

@@ -0,0 +1,83 @@
use <line3d.scad>;
/* [Basic] */
stick_leng = 80;
stick_diameter = 5;
inner_square_leng = 60;
leng_diff = 1.75;
min_leng = 13;
stick_fn = 24;
/* [Advanced] */
cap_style = "CAP_CIRCLE"; // [CAP_BUTT, CAP_CIRCLE, CAP_SPHERE]
angle_offset = 5;
layer_offset = 1.2;
module stick_square(inner_square_leng, stick_leng, stick_diameter, cap_style) {
diff_leng = stick_leng - inner_square_leng;
half_inner_square_leng = inner_square_leng / 2;
half_stick_leng = stick_leng / 2;
module stick() {
line3d(
[0, -half_stick_leng, 0],
[0, half_stick_leng, 0],
stick_diameter,
cap_style,
cap_style
);
}
module sticks() {
translate([-half_inner_square_leng, 0, 0])
stick();
translate([half_inner_square_leng, 0, 0])
stick();
}
sticks();
translate([0, 0, stick_diameter])
rotate(90)
sticks();
}
module spiral_stack(orig_leng, orig_height, current_leng, leng_diff, min_leng, angle_offset, pre_height = 0, i = 0) {
if(current_leng > min_leng) {
angle = atan2(leng_diff, current_leng - leng_diff);
factor = current_leng / orig_leng;
translate([0, 0, pre_height])
scale(factor)
children();
next_square_leng = sqrt(pow(leng_diff, 2) + pow(current_leng - leng_diff, 2));
height = factor * orig_height + pre_height;
rotate(angle + angle_offset)
spiral_stack(
orig_leng,
orig_height,
next_square_leng,
leng_diff,
min_leng,
angle_offset,
height,
i + 1
) children();
}
}
height = stick_diameter * layer_offset;
$fn = stick_fn;
spiral_stack(inner_square_leng, stick_diameter * 2, inner_square_leng, leng_diff, min_leng, angle_offset)
stick_square(
inner_square_leng,
stick_leng,
height,
cap_style
);