mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 17:24:20 +02:00
add worley_noise
This commit is contained in:
6
src/experimental/_impl/_worley_noise_impl.scad
Normal file
6
src/experimental/_impl/_worley_noise_impl.scad
Normal 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])]);
|
10
src/experimental/worley_noise.scad
Normal file
10
src/experimental/worley_noise.scad
Normal 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);
|
Reference in New Issue
Block a user