1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/docs/lib3x-nz_cell.md

47 lines
1.4 KiB
Markdown
Raw Normal View History

2020-04-08 09:33:25 +08:00
# nz_cell
It's an implementation of [Worley noise](https://en.wikipedia.org/wiki/Worley_noise). The feature points can be customized. The function returns `[cell_x, cell_y(, cell_z), noise]` value at the (x, y(,z)) coordinate.
**Since:** 2.3
## Parameters
2020-12-16 16:25:16 +08:00
2020-04-08 09:33:25 +08:00
- `points` : The feature points, can be 2D or 3D.
- `p` : The pixel or voxel coordinate.
- `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_cell.scad>
use <golden_spiral.scad>
2020-04-08 09:33:25 +08:00
size = [100, 50];
half_size = size / 2;
pts_angles = golden_spiral(
from = 3,
to = 10,
point_distance = 3
);
feature_points = [for(pt_angle = pts_angles) pt_angle[0] + half_size];
noised = [
2022-04-06 17:44:11 +08:00
for(y = [0:size.y - 1], x = [0:size.x - 1])
[x, y, nz_cell(feature_points, [x, y])]
2020-04-08 09:33:25 +08:00
];
max_dist = max([for(n = noised) n[2]]);
for(n = noised) {
c = abs(n[2] / max_dist);
color([c, c, c])
linear_extrude(n[2] + 0.1)
translate([n[0], n[1]])
square(1);
}
2021-02-24 21:09:54 +08:00
![nz_cell](images/lib3x-nz_cell-1.JPG)
2020-04-08 09:33:25 +08:00
2020-04-08 13:05:24 +08:00
You can build a model such as [voronoi_fibonacci2](https://github.com/JustinSDK/dotSCAD/blob/master/examples/voronoi/voronoi_fibonacci2.scad):
2020-04-08 09:33:25 +08:00
2021-02-24 21:09:54 +08:00
![nz_cell](images/lib3x-nz_cell-2.JPG)