1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-11 01:04:07 +02:00

add worley_noise

This commit is contained in:
Justin Lin
2020-03-28 11:26:29 +08:00
parent 6eb241e768
commit 6fbf01648e
2 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
use <experimental/sum.scad>;
function _manhattan(v) = sum([for(d = v) abs(d)]);
function _chebyshev(p1, p2) =
max([for(i = [0:len(p1) - 1]) abs(p1[i] - p2[i])]);

View File

@@ -0,0 +1,10 @@
use <experimental/_impl/_worley_noise_impl.scad>;
function worley_noise(p, points, dist = "euclidean") =
let(
dists = dist == "euclidean" ? [for(i = [0:len(points) - 1]) norm(points[i] - p)] :
dist == "manhattan" ? [for(i = [0:len(points) - 1]) _manhattan(points[i] - p)] :
dist == "chebyshev" ? [for(i = [0:len(points) - 1]) _chebyshev(points[i], p)] :
assert("Unknown distance option")
)
min(dists);