From 1e1587c600c491947ff0dc36740ce4d674260510 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 30 Jul 2022 09:11:12 +0800 Subject: [PATCH] add spiral_ripples --- examples/spiral/spiral_ripples.scad | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 examples/spiral/spiral_ripples.scad diff --git a/examples/spiral/spiral_ripples.scad b/examples/spiral/spiral_ripples.scad new file mode 100644 index 00000000..4f798146 --- /dev/null +++ b/examples/spiral/spiral_ripples.scad @@ -0,0 +1,42 @@ +use +use +use +use +use + +amplitude = 2; +angle_step = 30; +voxel_step = 0.2; +wave_step = 0.1; +thickness = 0.5; +dist = "euclidean"; // [euclidean, manhattan, chebyshev, border] +seed = 51; + +spiral_ripples(); + +module spiral_ripples() { + phi = (1 + sqrt(5)) / 2; + degrees = 720; + points = [ + for(d = [0:angle_step:degrees]) + let( + theta = radians(d), + r = pow(phi, theta * 2 / PI) + ) + r * [cos(d), sin(d)] + ]; + + sf = [ + for(y = [-45:voxel_step:30]) + [ + for(x = [-40:voxel_step:70]) + let( + nz = nz_cell(points, [x, y], dist), + n = amplitude * nz_perlin2(nz + x * wave_step, nz + y * wave_step, seed) + ) + [x, y, n] + ] + ]; + + sf_thicken(sf, thickness); +} \ No newline at end of file