mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
add docs
This commit is contained in:
parent
24157ceb24
commit
22a6891f8b
@ -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
|
||||
|
BIN
docs/images/lib2x-nz_perlin3-1.JPG
Normal file
BIN
docs/images/lib2x-nz_perlin3-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 65 KiB |
BIN
docs/images/lib2x-nz_perlin3s-1.JPG
Normal file
BIN
docs/images/lib2x-nz_perlin3s-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 99 KiB |
34
docs/lib2x-nz_perlin3.md
Normal file
34
docs/lib2x-nz_perlin3.md
Normal 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)
|
@ -1,25 +1,20 @@
|
||||
use <util/rand.scad>;
|
||||
use <noise/nz_perlin2s.scad>;
|
||||
use <noise/nz_perlin3s.scad>;
|
||||
# nz_perlin3s
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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 demo2() {
|
||||
points = [
|
||||
for(y = [0:.2:10])
|
||||
[
|
||||
@ -27,9 +22,9 @@ module demo2() {
|
||||
[x, y]
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
seed = rand(0, 256);
|
||||
|
||||
|
||||
points_with_h = [
|
||||
for(ri = [0:len(points) - 1])
|
||||
let(ns = nz_perlin2s(points[ri], seed))
|
||||
@ -38,7 +33,7 @@ module demo2() {
|
||||
[points[ri][ci][0], points[ri][ci][1], ns[ci] + 1]
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
h_scale = 1.5;
|
||||
for(row = points_with_h) {
|
||||
for(i = [0:len(row) - 1]) {
|
||||
@ -50,21 +45,17 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
color("LimeGreen")
|
||||
linear_extrude(.2)
|
||||
square(10);
|
||||
}
|
||||
|
||||
demo1();
|
||||
|
||||
translate([8, 0])
|
||||
demo2();
|
||||
![nz_perlin3s](images/lib2x-nz_perlin3s-1.JPG)
|
@ -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>;
|
||||
|
||||
|
@ -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>;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user