1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-16 21:58:26 +01:00

move to pp

This commit is contained in:
Justin Lin 2022-06-19 11:47:54 +08:00
parent 2651a23524
commit 938507d02d
10 changed files with 28 additions and 22 deletions

View File

@ -397,8 +397,13 @@ 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.
## Point Picking
Signature | Description
--|--
[**pp/pp_disk**(radius, value_count[, seed])](https://openhome.cc/eGossip/OpenSCAD/lib3x-pp_disk.html) | generate random points over a disk.
[**pp/pp_sphere**(radius, value_count[, seed])](https://openhome.cc/eGossip/OpenSCAD/lib3x-pp_sphere.html) | pick random points on the surface of a sphere.
## Maze

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -1,4 +1,4 @@
# rands_disk
# pp_disk
Generate random points over a disk.
@ -12,16 +12,16 @@ Generate random points over a disk.
## Examples
use <util/rands_disk.scad>
use <pp/pp_disk.scad>
number = 10000;
radius = 2;
points = rands_disk(radius, number);
points = pp_disk(radius, number);
for(p = points) {
translate(p)
circle(.01);
}
![rands_disk](images/lib3x-rands_disk-1.JPG)
![rands_disk](images/lib3x-pp_disk-1.JPG)

View File

@ -1,4 +1,4 @@
# rands_sphere
# pp_sphere
Pick random points on the surface of a sphere.
@ -12,12 +12,12 @@ Pick random points on the surface of a sphere.
## Examples
use <util/rands_sphere.scad>
use <pp/pp_sphere.scad>
number = 1000;
radius = 2;
points = rands_sphere(radius, number);
points = pp_sphere(radius, number);
for(p = points) {
@ -27,4 +27,4 @@ Pick random points on the surface of a sphere.
%sphere(radius, $fn = 48);
![rands_sphere](images/lib3x-rands_sphere-1.JPG)
![rands_sphere](images/lib3x-pp_sphere-1.JPG)

View File

@ -1,6 +1,6 @@
use <voronoi/vrn_sphere.scad>
use <polyline_join.scad>
use <util/rands_sphere.scad>
use <pp/pp_sphere.scad>
use <experimental/r_union3.scad>
eyelets = 800;
@ -9,7 +9,7 @@ radius = 50;
voronoi_melon(eyelets, radius);
module voronoi_melon(eyelets, radius) {
pts = rands_sphere(radius, eyelets);
pts = pp_sphere(radius, eyelets);
cells = vrn_sphere(pts);
color("DarkKhaki")

View File

@ -3,13 +3,13 @@ use <polyline_join.scad>
use <sweep.scad>
use <fibonacci_lattice.scad>
use <experimental/convex_centroid.scad>
use <util/rands_sphere.scad>
use <pp/pp_sphere.scad>
n = 60;
radius = 5;
// pts = fibonacci_lattice(n, radius);
pts = rands_sphere(radius, n);
pts = pp_sphere(radius, n);
region_hollow = true;
region_offset = 0.2;

View File

@ -29,7 +29,8 @@ new:
doc-ed
deprecated:
- util/sort, util/bsearch, util/has, util/rands_disk, util/rands_sphere
- util/sort, util/bsearch, util/has
- pp/pp_disk, pp/pp_sphere
- maze/mz_square_cells, maze/mz_theta_cells, maze/mz_square_walls, maze/mz_hex_walls
- rails2sections

View File

@ -1,14 +1,14 @@
/**
* rands_disk.scad
* pp_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
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-pp_disk.html
*
**/
function rands_disk(radius, value_count, seed = undef) =
function pp_disk(radius, value_count, seed = undef) =
let(
seed_undef = is_undef(seed),
n = value_count * 2,

View File

@ -1,16 +1,16 @@
/**
* rands_sphere.scad
* pp_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
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-pp_sphere.html
*
**/
use <degrees.scad>
use <../util/degrees.scad>
function rands_sphere(radius, value_count, seed = undef) =
function pp_sphere(radius, value_count, seed = undef) =
let(r_nums = is_undef(seed) ? rands(0, 1, value_count * 2) : rands(0, 1, value_count * 2, seed))
[
for(i = [0:value_count - 1])