1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-23 09:03:58 +01:00
dotSCAD/docs/lib2x-dedup.md

45 lines
1.2 KiB
Markdown
Raw Normal View History

2020-03-19 09:14:42 +08:00
# dedup
2020-03-27 13:57:57 +08:00
Eliminating duplicate copies of repeating vectors. If `lt` has a large number of elements, sorting `lt` first and setting `sorted` to `true` will be faster.
2020-03-19 09:14:42 +08:00
**Since:** 2.3
## Parameters
- `lt` : A list of vectors.
2020-03-19 17:02:07 +08:00
- `sorted` : If `false` (default), use native `search`. If `true`, `lt` must be sorted by zyx (from the last index to the first one) and `dedup` will use binary search internally.
2020-03-19 09:14:42 +08:00
## 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]];
2020-03-19 17:02:07 +08:00
sorted_pts = sort(concat(pts1, pts2), by = "vt");
2020-03-19 09:14:42 +08:00
// simple union
pts3 = dedup(sorted_pts, sorted = true);
for(p = pts3) {
translate(p)
square(1, center = true);
}
![dedup](images/lib2x-dedup-2.JPG)