1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-09-01 10:42:57 +02:00

update readme

This commit is contained in:
Justin Lin
2022-06-14 08:56:43 +08:00
parent 45050f31cd
commit 273f83bd27
8 changed files with 81 additions and 39 deletions

View File

@@ -397,6 +397,8 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp
[**util/contains**(lt, elem)](https://openhome.cc/eGossip/OpenSCAD/lib3x-contains.html) | return `true` if `lt` contains `elem`.
[**util/binary_search**(sorted, target[, lo, hi])](https://openhome.cc/eGossip/OpenSCAD/lib3x-binary_search.html) | search a value in a sorted list.
[**util/count**(lt, test)](https://openhome.cc/eGossip/OpenSCAD/lib3x-count.html) | return the number of times `test` return `true` in the list.
[**util/rands_disk**(radius, value_count[, seed])](https://openhome.cc/eGossip/OpenSCAD/lib3x-rands_disk.html) | generate random points over a disk.
[**util/rands_sphere**(radius, value_count[, seed])](https://openhome.cc/eGossip/OpenSCAD/lib3x-rands_sphere.html) | pick random points on the surface of a sphere.
## Maze

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

27
docs/lib3x-rands_disk.md Normal file
View File

@@ -0,0 +1,27 @@
# rands_disk
Generate random points over a disk.
**Since:** 3.3
## Parameters
- `radius` : The radius of the disk.
- `value_count` : Number of random numbers to return as a vector.
- `seed_value` : Optional. Seed value for random number generator for repeatable results.
## Examples
use <util/rands_disk.scad>
number = 10000;
radius = 2;
points = rands_disk(radius, number);
for(p = points) {
translate(p)
circle(.01);
}
![rands_disk](images/lib3x-rands_disk-1.JPG)

View File

@@ -0,0 +1,30 @@
# rands_disk
Pick random points on the surface of a sphere.
**Since:** 3.3
## Parameters
- `radius` : The radius of the sphere.
- `value_count` : Number of random numbers to return as a vector.
- `seed_value` : Optional. Seed value for random number generator for repeatable results.
## Examples
use <util/rands_sphere.scad>
number = 1000;
radius = 2;
points = rands_sphere(radius, number);
for(p = points) {
translate(p)
sphere(.05);
}
%sphere(radius, $fn = 48);
![rands_sphere](images/lib3x-rands_sphere-1.JPG)

View File

@@ -18,11 +18,9 @@ new:
- t3d - roll/pitch/forward
- polyline_join: doc multi-childs
- util/count
- lemniscate_curve?
- perlin_sphere?
- rands_disk, rands_sphere?
- m_replace?
@@ -31,7 +29,7 @@ new:
doc-ed
deprecated:
- util/sort, util/bsearch, util/has
- util/sort, util/bsearch, util/has, util/rands_disk, util/rands_sphere
- maze/mz_square_cells, maze/mz_theta_cells, maze/mz_square_walls, maze/mz_hex_walls
- rails2sections

View File

@@ -1,3 +1,13 @@
/**
* rands_disk.scad
*
* @copyright Justin Lin, 2022
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-rands_disk.html
*
**/
function rands_disk(radius, value_count, seed = undef) =
let(
seed_undef = is_undef(seed),
@@ -9,18 +19,4 @@ function rands_disk(radius, value_count, seed = undef) =
for(i = [0:value_count - 1])
[cos(theta[i]), sin(theta[i])] * sqrt(k[i])
];
/*
use <util/rands_disk.scad>
number = 10000;
radius = 2;
points = rands_disk(radius, number);
for(p = points) {
translate(p)
circle(.01);
}
%circle(radius, $fn = 96);*/

View File

@@ -1,3 +1,13 @@
/**
* rands_sphere.scad
*
* @copyright Justin Lin, 2022
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-rands_sphere.html
*
**/
use <degrees.scad>
function rands_sphere(radius, value_count, seed = undef) =
@@ -14,24 +24,3 @@ function rands_sphere(radius, value_count, seed = undef) =
)
[x, y, z]
] * radius;
/*
use <util/rands_sphere.scad>
use <polyhedron_hull.scad>
number = 20;
radius = 2;
points = rands_sphere(radius, number);
polyhedron_hull(points);
for(p = points) {
translate(p)
sphere(.05);
}
%sphere(radius, $fn = 48);
*/