1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-14 02:34:12 +02:00

add dedup doc

This commit is contained in:
Justin Lin
2020-03-19 09:14:42 +08:00
parent 327d3b4a29
commit ac072e6c1b
4 changed files with 55 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

45
docs/lib2x-dedup.md Normal file
View File

@@ -0,0 +1,45 @@
# dedup
Eliminating duplicate copies of repeating vectors. If `lt` has many elements, sorting `lt` first and setting `sorted` to `true` will be faster.
**Since:** 2.3
## Parameters
- `lt` : A list of vectors.
- `sorted` : If `false` (default), use native `search`. If `true`, `lt` must be sorted by zyx (from the last idx to first) and `dedup` will use binary search internally.
## Examples
use <pixel/px_circle.scad>;
use <util/dedup.scad>;
pts1 = px_circle(10, filled = true);
pts2 = [for(p = px_circle(5, filled = true)) p + [10, 0]];
// simple union
pts3 = dedup(concat(pts1, pts2));
for(p = pts3) {
translate(p)
square(1, center = true);
}
![dedup](images/lib2x-dedup-1.JPG)
use <pixel/px_circle.scad>;
use <util/sort.scad>;
use <util/dedup.scad>;
pts1 = px_circle(20, filled = true);
pts2 = [for(p = px_circle(10, filled = true)) p + [20, 0]];
sorted_pts = sort(sort(concat(pts1, pts2), by = "x"), by = "y");
// simple union
pts3 = dedup(sorted_pts, sorted = true);
for(p = pts3) {
translate(p)
square(1, center = true);
}
![dedup](images/lib2x-dedup-2.JPG)

View File

@@ -1,3 +1,13 @@
/**
* dedup.scad
*
* @copyright Justin Lin, 2020
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-dedup.html
*
**/
use <util/_impl/_dedup_impl.scad>;
function dedup(lt, sorted = false) =