2020-04-06 17:42:48 +08:00
# nz_worley2s
Returns 2D [Worley noise ](https://en.wikipedia.org/wiki/Worley_noise ) values `[cell_x, cell_y, noise]` at (x, y) coordinates.
2020-04-07 17:34:27 +08:00
It divides the space into grids. The nucleus of each cell is randomly placed in a grid.
2020-04-06 17:42:48 +08:00
2021-02-24 21:09:54 +08:00
![nz_worley2s ](images/lib3x-nz_worley2s-1.JPG )
2020-04-06 17:42:48 +08:00
**Since:** 2.3
## Parameters
- `points` : A list of `[x, y]` coordinates.
- `seed` : The random seed. If it's ignored, a randomized value will be used.
2020-04-07 17:34:27 +08:00
- `grid_w` : The grid width. Default to 10. Smaller `grid_w` makes more cells.
2020-04-06 17:42:48 +08:00
- `dist` : The noise value of each point is based on its distance to other cells. Different distance strategies make different noises. The `dist` parameter accepts `"euclidean"` , `"manhattan"` , `"chebyshev"` or `"border"` .
## Examples
2022-06-06 13:11:46 +08:00
use < noise / nz_worley2s . scad >
2020-04-06 17:42:48 +08:00
size = [100, 50];
2020-04-07 17:34:27 +08:00
grid_w = 10;
2020-04-06 17:42:48 +08:00
dist = "euclidean"; // [euclidean, manhattan, chebyshev, border]
seed = 51;
points = [
2022-04-06 17:44:11 +08:00
for(y = [0:size.y - 1], x = [0:size.x - 1])
[x, y]
2020-04-06 17:42:48 +08:00
];
2020-04-07 17:34:27 +08:00
cells = nz_worley2s(points, seed, grid_w, dist);
2020-04-06 17:42:48 +08:00
for(i = [0:len(cells) - 1]) {
h = norm([cells[i][0], cells[i][1]]) % 10;
color([h, h, h] / 10)
linear_extrude(h)
translate(points[i])
square(1);
}
2021-02-24 21:09:54 +08:00
![nz_worley2s ](images/lib3x-nz_worley2s-2.JPG )