From e932cdaa0f60ead2a705fa2bd494ff717e5f1874 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 9 May 2022 13:37:01 +0800 Subject: [PATCH] add rock_horn --- examples/voronoi/rock_horn.scad | 71 +++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 examples/voronoi/rock_horn.scad diff --git a/examples/voronoi/rock_horn.scad b/examples/voronoi/rock_horn.scad new file mode 100644 index 00000000..de4a38ac --- /dev/null +++ b/examples/voronoi/rock_horn.scad @@ -0,0 +1,71 @@ +use ; +use ; +use ; +use ; +use ; + +detail = 4; +seed = 5; + +rock_horn(detail, seed); + +module rock_horn(detail, seed) { + $fn = 64 * detail; + point_distance = 1 / detail; + + scale = 4; + radius = 6; + thickness = 1.5; + + c = shape_circle(radius = radius); + + pts_angles = golden_spiral( + from = 8, + to = 8, + point_distance = point_distance, + rt_dir = "CT_CLK" + ); + + leng = len(pts_angles); + scale_step = scale / leng; + h_step = 2 * scale * radius / leng; + sections = [ + for(i = [0:leng - 1]) + let( + pts = [ + for(p = c) + let( + s = 1 + scale_step * i, + nzp = [p.x * s, p.y * s, h_step * i], + nz = nz_worley3(nzp.x, nzp.y, nzp.z, seed, radius, "border") + ) + [nzp.x, nzp.y, 0] + [sign(p.x), sign(p.y), 0] * nz[3] / scale + ] + ) + [ + each pts, + each [ + for(p = pts) + p - [sign(p.x), sign(p.y), 0] * thickness + ] + ] + ] / scale; + + rx = [90, 0, 0]; + sweep( + [ + for(i = [0:leng - 1]) + let( + section = sections[i], + pt_angle = pts_angles[i], + off = [pt_angle[0].x, pt_angle[0].y, 0], + a = pt_angle[1] + ) + [ + for(p = section) + off + ptf_rotate(ptf_rotate(p, rx), a) + ] + ], + "HOLLOW" + ); +} \ No newline at end of file