1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 06:08:31 +01:00

add type, one_spiral params

This commit is contained in:
Justin Lin 2022-06-05 21:01:58 +08:00
parent 9333145a6d
commit 6bfe94ce1c

View File

@ -3,13 +3,16 @@ use <util/radians.scad>;
use <util/lerp.scad>; use <util/lerp.scad>;
use <ptf/ptf_rotate.scad>; use <ptf/ptf_rotate.scad>;
spirals = 8; spirals = 7;
start_n = 1; // spiral start from 360 / spirals * start_n start_n = 1; // spiral start from 360 / spirals * start_n
degrees = 150; degrees = 150;
thickness = 2.5; thickness = 2.5;
offset_r = 0.4; offset_r = 0.4;
$fn = 24; $fn = 24;
model = "ALL";
one_spiral = false;
golden_spiral_jigsaw(); golden_spiral_jigsaw();
module golden_spiral_jigsaw() { module golden_spiral_jigsaw() {
@ -71,89 +74,93 @@ module golden_spiral_jigsaw() {
polygons = piece_polygons(start, a_step, degrees * 2); polygons = piece_polygons(start, a_step, degrees * 2);
for(i = [0:spirals - 1]) { if(model != "PLATE") {
rotate(a_step * i) for(i = [0:one_spiral ? 0 : spirals - 1]) {
for(j = [0:len(polygons) - 5]) { rotate(a_step * i)
poly = polygons[j]; for(j = [0:len(polygons) - 5]) {
u_poly = polygons[j + 1]; poly = polygons[j];
r_poly = [ u_poly = polygons[j + 1];
for(p = polygons[j + 4]) r_poly = [
ptf_rotate(p, a_step * (spirals - 1)) for(p = polygons[j + 4])
]; ptf_rotate(p, a_step * (spirals - 1))
];
// a piece with blanks
difference() { // a piece with blanks
offset(-offset_rr / 2) difference() {
polygon(poly); offset(-offset_rr / 2)
polygon(poly);
interlocking_part1(u_poly, offset_rr);
interlocking_part2(r_poly, offset_rr); interlocking_part1(u_poly, offset_rr);
interlocking_part2(r_poly, offset_rr);
}
// tabs
interlocking_part1(poly, 0);
interlocking_part2(poly, 0);
} }
// tabs
interlocking_part1(poly, 0);
interlocking_part2(poly, 0);
} }
} }
// plate if(model != "SPIRALS") {
polygons2 = piece_polygons(-a_step, a_step, start + a_step * 4); // plate
points = [ polygons2 = piece_polygons(-a_step, a_step, start + a_step * 4);
for(d = [-start:a_step / 4:start]) points = [
let( for(d = [-start:a_step / 4:start])
theta = radians(d), let(
r = pow(phi, theta * 2 / PI) theta = radians(d),
) r = pow(phi, theta * 2 / PI)
r * [cos(d), sin(d)] )
]; r * [cos(d), sin(d)]
];
render()
difference() { render()
union() { difference() {
for(i = [0:spirals - 1]) { union() {
rotate(a_step * i) for(i = [0:spirals - 1]) {
difference() { rotate(a_step * i)
difference() {
offset(-offset_rr / 2)
union() offset(-offset_rr / 2)
for(j = [0:len(polygons2) - 13]) { union()
poly = polygons2[j]; for(j = [0:len(polygons2) - 13]) {
polygon(poly); poly = polygons2[j];
} polygon(poly);
}
for(j = [0:len(polygons2) - 5]) {
poly = polygons2[j]; for(j = [0:len(polygons2) - 5]) {
// a piece with blanks poly = polygons2[j];
difference() { // a piece with blanks
//polygon(poly); difference() {
u_poly = polygons2[j + 1]; //polygon(poly);
r_poly = [ u_poly = polygons2[j + 1];
for(p = polygons2[j + 4]) r_poly = [
ptf_rotate(p, a_step * (spirals - 1)) for(p = polygons2[j + 4])
]; ptf_rotate(p, a_step * (spirals - 1))
];
union() {
if(j >= start_n * 4) { union() {
interlocking_part2(r_poly, offset_rr); if(j >= start_n * 4) {
} interlocking_part2(r_poly, offset_rr);
}
if(j >= start_n * 4 + 3) { if(j >= start_n * 4 + 3) {
interlocking_part1(u_poly, offset_rr); interlocking_part1(u_poly, offset_rr);
} }
} }
}
} }
} }
} }
circle(pow(phi, radians(start) / PI) * 0.95);
}
union()
for(i = [0:spirals - 1]) {
rotate(a_step * i)
polyline_join(points)
circle(offset_rr / 2);
} }
circle(pow(phi, radians(start) / PI) * 0.95);
}
union()
for(i = [0:spirals - 1]) {
rotate(a_step * i)
polyline_join(points)
circle(offset_rr / 2);
} }
} }
} }