1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
This commit is contained in:
Justin Lin 2020-04-06 13:17:50 +08:00
parent 24157ceb24
commit 22a6891f8b
7 changed files with 78 additions and 33 deletions

View File

@ -194,8 +194,8 @@ See [examples](examples).
- [noise/nz_perlin1s](https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin1s.html)
- [noise/nz_perlin2](https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin2.html)
- [noise/nz_perlin2s](https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin2s.html)
- noise/nz_perlin3
- noise/nz_perlin3s
- [noise/nz_perlin3](https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin3.html)
- [noise/nz_perlin3s](https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin3s.html)
- noise/nz_worley1
- noise/nz_worley1s
- noise/nz_worley2

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

34
docs/lib2x-nz_perlin3.md Normal file
View File

@ -0,0 +1,34 @@
# nz_perlin3
Returns the 3D [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise) value at the (x, y, z) coordinate.
**Since:** 2.3
## Parameters
- `x` : The x coordinate.
- `y` : The y coordinate.
- `z` : The z coordinate.
- `seed` : The random seed.
## Examples
use <util/rand.scad>;
use <noise/nz_perlin3.scad>;
seed = rand(0, 255);
noised = [
for(z = [0:.2:5])
for(y = [0:.2:5])
for(x = [0:.2:5])
[x, y, z, nz_perlin3(x, y, z, seed)]
];
for(nz = noised) {
if(nz[3] > 0.2) {
translate([nz[0], nz[1], nz[2]])
cube(.2);
}
}
![nz_perlin3](images/lib2x-nz_perlin3-1.JPG)

View File

@ -1,25 +1,20 @@
# nz_perlin3s
Returns 3D [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise) values at (x, y, z) coordinates.
**Since:** 2.3
## Parameters
- `points` : A list of `[x, y, z]` coordinates.
- `seed` : The random seed. If it's ignored, a randomized value will be used.
## Examples
use <util/rand.scad>;
use <noise/nz_perlin2s.scad>;
use <noise/nz_perlin3s.scad>;
module demo1() {
for(z = [0:.2:5]) {
points = [
for(y = [0:.2:5])
for(x = [0:.2:5])
[x, y, z]
];
noise = nz_perlin3s(points, 3);
for(i = [0:len(points) - 1]) {
alpha = abs(noise[i] + .5);
color([.75, .75, .75, alpha < 0 ? 0 : alpha > 1 ? 1 : alpha])
translate(points[i])
cube(.2);
}
}
}
module demo2() {
points = [
for(y = [0:.2:10])
[
@ -50,8 +45,8 @@ module demo2() {
for(j = [0:len(pts) - 1]) {
if(noise[j] > 0) {
color(
pts[j][2] < 1.25 ? "green" :
pts[j][2] < 1.75 ? "Olive" : "white")
pts[j][2] < 1 ? "green" :
pts[j][2] < 1.5 ? "Olive" : "white")
translate(pts[j])
cube(.2);
}
@ -62,9 +57,5 @@ module demo2() {
color("LimeGreen")
linear_extrude(.2)
square(10);
}
demo1();
translate([8, 0])
demo2();
![nz_perlin3s](images/lib2x-nz_perlin3s-1.JPG)

View File

@ -1,3 +1,13 @@
/**
* nz_perlin3.scad
*
* @copyright Justin Lin, 2020
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin3.html
*
**/
use <util/rand.scad>;
use <noise/_impl/_pnoise3_impl.scad>;

View File

@ -1,3 +1,13 @@
/**
* nz_perlin3s.scad
*
* @copyright Justin Lin, 2020
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin3s.html
*
**/
use <util/rand.scad>;
use <noise/_impl/_pnoise3_impl.scad>;