From af87c89ecc3397baac597d8370171b72e3aec539 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 28 Mar 2022 17:11:52 +0800 Subject: [PATCH] refactor: start from unit sphere --- src/experimental/worley_sphere.scad | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/experimental/worley_sphere.scad b/src/experimental/worley_sphere.scad index 4476ebfe..f9e23e89 100644 --- a/src/experimental/worley_sphere.scad +++ b/src/experimental/worley_sphere.scad @@ -2,22 +2,22 @@ use ; use ; use ; -// radius = 30; -// detail = 10; -// amplitude = .05; -// dist = "border"; // [euclidean, manhattan, chebyshev, border] +radius = 30; +detail = 10; +amplitude = .05; +dist = "border"; // [euclidean, manhattan, chebyshev, border] -// worley_sphere(radius, detail, amplitude, dist); +worley_sphere(radius, detail, amplitude, dist); module worley_sphere(radius, detail, amplitude, dist = "border", grid_w = undef, seed = undef) { gw = is_undef(grid_w) ? radius : grid_w; - points_faces = geom_icosahedron(radius, detail); + points_faces = geom_icosahedron(1, detail); points = points_faces[0]; faces = points_faces[1]; sd = is_undef(seed) ? rand() * 1000: seed; - noisy = nz_worley3s(points, sd, gw, dist); + noisy = nz_worley3s(points * radius, sd, gw, dist); noisy_points = [ for(i = [0:len(points) - 1]) @@ -25,7 +25,7 @@ module worley_sphere(radius, detail, amplitude, dist = "border", grid_w = undef, p = points[i], nz = noisy[i][3] ) - p / norm(p) * (radius + nz * amplitude) + p * (radius + nz * amplitude) ]; polyhedron(noisy_points, faces);