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

refactor: use hashset

This commit is contained in:
Justin Lin
2022-04-14 21:14:12 +08:00
parent ad5c2a984a
commit 5205a31bf2

View File

@@ -8,14 +8,16 @@
*
**/
use <../util/sort.scad>;
use <../util/has.scad>;
use <../util/set/hashset.scad>;
use <../util/set/hashset_has.scad>;
use <../__comm__/_pt3_hash.scad>;
function vx_intersection(points1, points2) =
let(
leng1 = len(points1),
leng2 = len(points2),
pts_pair = leng1 > leng2 ? [points1, points2] : [points2, points1],
sorted = sort(pts_pair[1], by = "vt")
hash = function(p) _pt3_hash(p),
sorted = hashset(pts_pair[1], hash = hash)
)
[for(p = pts_pair[0]) if(has(sorted, p, sorted = true)) p];
[for(p = pts_pair[0]) if(hashset_has(sorted, p, hash = hash)) p];