mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-14 10:44:48 +02:00
add dedup doc
This commit is contained in:
BIN
docs/images/lib2x-dedup-1.JPG
Normal file
BIN
docs/images/lib2x-dedup-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
docs/images/lib2x-dedup-2.JPG
Normal file
BIN
docs/images/lib2x-dedup-2.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
45
docs/lib2x-dedup.md
Normal file
45
docs/lib2x-dedup.md
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|

|
@@ -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>;
|
use <util/_impl/_dedup_impl.scad>;
|
||||||
|
|
||||||
function dedup(lt, sorted = false) =
|
function dedup(lt, sorted = false) =
|
||||||
|
Reference in New Issue
Block a user