mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-17 20:11:50 +02:00
refactor: include 1st class hash function
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
function _pt2_hash(p) =
|
_pt2_hash = function(p)
|
||||||
let(
|
let(
|
||||||
x = p.x >= 0 ? 2 * p.x : -2 * p.x - 1,
|
x = p.x >= 0 ? 2 * p.x : -2 * p.x - 1,
|
||||||
y = p.y >= 0 ? 2 * p.y : -2 * p.y - 1
|
y = p.y >= 0 ? 2 * p.y : -2 * p.y - 1
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
function _pt3_hash(p) =
|
_pt3_hash = function(p)
|
||||||
let(
|
let(
|
||||||
x = p.x >= 0 ? 2 * p.x : -2 * p.x - 1,
|
x = p.x >= 0 ? 2 * p.x : -2 * p.x - 1,
|
||||||
y = p.y >= 0 ? 2 * p.y : -2 * p.y - 1,
|
y = p.y >= 0 ? 2 * p.y : -2 * p.y - 1,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
function _str_hash(value) =
|
_str_hash = function(value)
|
||||||
let(
|
let(
|
||||||
chars = str(value),
|
chars = str(value),
|
||||||
end = len(chars) - 1
|
end = len(chars) - 1
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../__comm__/_pt2_hash.scad>;
|
|
||||||
use <_impl/_mz_hamiltonian_impl.scad>;
|
use <_impl/_mz_hamiltonian_impl.scad>;
|
||||||
use <mz_square.scad>;
|
use <mz_square.scad>;
|
||||||
use <mz_square_initialize.scad>;
|
use <mz_square_initialize.scad>;
|
||||||
@@ -16,6 +15,8 @@ use <mz_square_get.scad>;
|
|||||||
use <../util/set/hashset.scad>;
|
use <../util/set/hashset.scad>;
|
||||||
use <../util/set/hashset_elems.scad>;
|
use <../util/set/hashset_elems.scad>;
|
||||||
|
|
||||||
|
include <../__comm__/_pt2_hash.scad>;
|
||||||
|
|
||||||
function mz_hamiltonian(rows, columns, start = [0, 0], init_cells, seed) =
|
function mz_hamiltonian(rows, columns, start = [0, 0], init_cells, seed) =
|
||||||
let(
|
let(
|
||||||
init_cells_undef = is_undef(init_cells),
|
init_cells_undef = is_undef(init_cells),
|
||||||
@@ -42,7 +43,7 @@ function mz_hamiltonian(rows, columns, start = [0, 0], init_cells, seed) =
|
|||||||
dot_pts = hashset_elems(
|
dot_pts = hashset_elems(
|
||||||
hashset(
|
hashset(
|
||||||
all,
|
all,
|
||||||
hash = function(p) _pt2_hash(p)
|
hash = _pt2_hash
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
falseRow = [for(c = [0:c * 2]) false],
|
falseRow = [for(c = [0:c * 2]) false],
|
||||||
|
@@ -8,10 +8,11 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../__comm__/_str_hash.scad>;
|
|
||||||
use <_impl/_dedup_impl.scad>;
|
use <_impl/_dedup_impl.scad>;
|
||||||
|
|
||||||
function dedup(lt, eq = undef, hash = function(e) _str_hash(e), number_of_buckets) =
|
include <../__comm__/_str_hash.scad>;
|
||||||
|
|
||||||
|
function dedup(lt, eq = undef, hash = _str_hash, number_of_buckets) =
|
||||||
let(leng_lt = len(lt))
|
let(leng_lt = len(lt))
|
||||||
leng_lt < 2 ? lt :
|
leng_lt < 2 ? lt :
|
||||||
let(
|
let(
|
||||||
|
@@ -8,10 +8,10 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../../__comm__/_str_hash.scad>;
|
|
||||||
use <_impl/_hashmap_impl.scad>;
|
use <_impl/_hashmap_impl.scad>;
|
||||||
|
include <../../__comm__/_str_hash.scad>;
|
||||||
|
|
||||||
function hashmap(kv_lt, eq = undef, hash = function(e) _str_hash(e), number_of_buckets) =
|
function hashmap(kv_lt, eq = undef, hash = _str_hash, number_of_buckets) =
|
||||||
let(
|
let(
|
||||||
kv_lt_undef = is_undef(kv_lt),
|
kv_lt_undef = is_undef(kv_lt),
|
||||||
leng_kv_lt = kv_lt_undef ? -1 : len(kv_lt),
|
leng_kv_lt = kv_lt_undef ? -1 : len(kv_lt),
|
||||||
|
@@ -8,10 +8,10 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../../__comm__/_str_hash.scad>;
|
|
||||||
use <../_impl/_find_eq.scad>;
|
use <../_impl/_find_eq.scad>;
|
||||||
|
include <../../__comm__/_str_hash.scad>;
|
||||||
|
|
||||||
function hashmap_del(map, key, eq = undef, hash = function(e) _str_hash(e)) =
|
function hashmap_del(map, key, eq = undef, hash = _str_hash) =
|
||||||
let(
|
let(
|
||||||
bidx = hash(key) % len(map),
|
bidx = hash(key) % len(map),
|
||||||
bucket = map[bidx],
|
bucket = map[bidx],
|
||||||
|
@@ -8,10 +8,10 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../../__comm__/_str_hash.scad>;
|
|
||||||
use <../_impl/_find_eq.scad>;
|
use <../_impl/_find_eq.scad>;
|
||||||
|
include <../../__comm__/_str_hash.scad>;
|
||||||
|
|
||||||
function hashmap_get(map, key, eq = undef, hash = function(e) _str_hash(e)) =
|
function hashmap_get(map, key, eq = undef, hash = _str_hash) =
|
||||||
let(
|
let(
|
||||||
bidx = hash(key) % len(map),
|
bidx = hash(key) % len(map),
|
||||||
bucket = map[bidx]
|
bucket = map[bidx]
|
||||||
|
@@ -8,8 +8,9 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../../__comm__/_str_hash.scad>;
|
|
||||||
use <_impl/_hashmap_put_impl.scad>;
|
use <_impl/_hashmap_put_impl.scad>;
|
||||||
|
|
||||||
function hashmap_put(map, key, value, eq = undef, hash = function(e) _str_hash(e)) =
|
include <../../__comm__/_str_hash.scad>;
|
||||||
|
|
||||||
|
function hashmap_put(map, key, value, eq = undef, hash = _str_hash) =
|
||||||
_hashmap_put(map, len(map), key, value, eq, hash);
|
_hashmap_put(map, len(map), key, value, eq, hash);
|
@@ -8,11 +8,12 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../../__comm__/_str_hash.scad>;
|
|
||||||
use <_impl/_hashset_impl.scad>;
|
use <_impl/_hashset_impl.scad>;
|
||||||
use <_impl/_hashset_add_impl.scad>;
|
use <_impl/_hashset_add_impl.scad>;
|
||||||
|
|
||||||
function hashset(lt, eq = undef, hash = function(e) _str_hash(e), number_of_buckets) =
|
include <../../__comm__/_str_hash.scad>;
|
||||||
|
|
||||||
|
function hashset(lt, eq = undef, hash = _str_hash, number_of_buckets) =
|
||||||
let(
|
let(
|
||||||
lt_undef = is_undef(lt),
|
lt_undef = is_undef(lt),
|
||||||
leng_lt = lt_undef ? -1 : len(lt),
|
leng_lt = lt_undef ? -1 : len(lt),
|
||||||
|
@@ -8,8 +8,9 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../../__comm__/_str_hash.scad>;
|
|
||||||
use <_impl/_hashset_add_impl.scad>;
|
use <_impl/_hashset_add_impl.scad>;
|
||||||
|
|
||||||
function hashset_add(set, elem, eq = undef, hash = function(e) _str_hash(e)) =
|
include <../../__comm__/_str_hash.scad>;
|
||||||
|
|
||||||
|
function hashset_add(set, elem, eq = undef, hash = _str_hash) =
|
||||||
_hashset_add(set, len(set), elem, eq, hash);
|
_hashset_add(set, len(set), elem, eq, hash);
|
@@ -8,10 +8,11 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../../__comm__/_str_hash.scad>;
|
|
||||||
use <../_impl/_find_eq.scad>;
|
use <../_impl/_find_eq.scad>;
|
||||||
|
|
||||||
function hashset_del(set, elem, eq = undef, hash = function(e) _str_hash(e)) =
|
include <../../__comm__/_str_hash.scad>;
|
||||||
|
|
||||||
|
function hashset_del(set, elem, eq = undef, hash = _str_hash) =
|
||||||
let(
|
let(
|
||||||
leng_set = len(set),
|
leng_set = len(set),
|
||||||
bidx = hash(elem) % leng_set,
|
bidx = hash(elem) % leng_set,
|
||||||
|
@@ -8,9 +8,10 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../../__comm__/_str_hash.scad>;
|
|
||||||
use <../_impl/_find_eq.scad>;
|
use <../_impl/_find_eq.scad>;
|
||||||
|
|
||||||
function hashset_has(set, elem, eq = undef, hash = function(e) _str_hash(e)) =
|
include <../../__comm__/_str_hash.scad>;
|
||||||
|
|
||||||
|
function hashset_has(set, elem, eq = undef, hash = _str_hash) =
|
||||||
let(bucket = set[hash(elem) % len(set)])
|
let(bucket = set[hash(elem) % len(set)])
|
||||||
bucket != [] && _find_eq(bucket, elem, eq) != -1;
|
bucket != [] && _find_eq(bucket, elem, eq) != -1;
|
@@ -1,9 +1,10 @@
|
|||||||
use <../../__comm__/_pt2_hash.scad>;
|
|
||||||
use <../../lines_intersection.scad>;
|
use <../../lines_intersection.scad>;
|
||||||
use <_convex_ct_clk_order.scad>;
|
use <_convex_ct_clk_order.scad>;
|
||||||
use <../../util/set/hashset.scad>;
|
use <../../util/set/hashset.scad>;
|
||||||
use <../../util/set/hashset_elems.scad>;
|
use <../../util/set/hashset_elems.scad>;
|
||||||
|
|
||||||
|
include <../../__comm__/_pt2_hash.scad>;
|
||||||
|
|
||||||
function _in_convex_r(i, j, preC, convex_pts, pt, leng, convex_pts, pt) =
|
function _in_convex_r(i, j, preC, convex_pts, pt, leng, convex_pts, pt) =
|
||||||
j == leng || (
|
j == leng || (
|
||||||
let(c = cross(convex_pts[i] - pt, convex_pts[j] - pt))
|
let(c = cross(convex_pts[i] - pt, convex_pts[j] - pt))
|
||||||
@@ -28,7 +29,7 @@ function _intersection_ps(closed_shape, line_pts, epsilon) =
|
|||||||
)
|
)
|
||||||
leng < 2 ? npts :
|
leng < 2 ? npts :
|
||||||
leng == 2 ? (npts[0] != npts[1] ? npts : [npts[0]]) :
|
leng == 2 ? (npts[0] != npts[1] ? npts : [npts[0]]) :
|
||||||
hashset_elems(hashset(npts, hash = function(p) _pt2_hash(p)));
|
hashset_elems(hashset(npts, hash = _pt2_hash));
|
||||||
|
|
||||||
function _convex_intersection(shape1, shape2, epsilon = 0.0001) =
|
function _convex_intersection(shape1, shape2, epsilon = 0.0001) =
|
||||||
(shape1 == [] || shape2 == []) ? [] :
|
(shape1 == [] || shape2 == []) ? [] :
|
||||||
|
@@ -1,15 +1,16 @@
|
|||||||
use <../../util/set/hashset.scad>;
|
use <../../util/set/hashset.scad>;
|
||||||
use <../../util/set/hashset_has.scad>;
|
use <../../util/set/hashset_has.scad>;
|
||||||
use <../../__comm__/_pt2_hash.scad>;
|
|
||||||
|
include <../../__comm__/_pt2_hash.scad>;
|
||||||
|
|
||||||
hash = function(p) _pt2_hash(p);
|
hash = function(p) _pt2_hash(p);
|
||||||
|
|
||||||
function _vx_contour_corner_value(pts, x, y) =
|
function _vx_contour_corner_value(pts, x, y) =
|
||||||
let(
|
let(
|
||||||
c1 = hashset_has(pts, [x, y - 1], hash = hash) || hashset_has(pts, [x - 1, y - 1], hash = hash) ? 1 : 0,
|
c1 = hashset_has(pts, [x, y - 1], hash = _pt2_hash) || hashset_has(pts, [x - 1, y - 1], hash = _pt2_hash) ? 1 : 0,
|
||||||
c2 = hashset_has(pts, [x - 1, y], hash = hash) || hashset_has(pts, [x - 1, y + 1], hash = hash) ? 2 : 0,
|
c2 = hashset_has(pts, [x - 1, y], hash = _pt2_hash) || hashset_has(pts, [x - 1, y + 1], hash = _pt2_hash) ? 2 : 0,
|
||||||
c3 = hashset_has(pts, [x, y + 1], hash = hash) || hashset_has(pts, [x + 1, y + 1], hash = hash) ? 4 : 0,
|
c3 = hashset_has(pts, [x, y + 1], hash = _pt2_hash) || hashset_has(pts, [x + 1, y + 1], hash = _pt2_hash) ? 4 : 0,
|
||||||
c4 = hashset_has(pts, [x + 1, y], hash = hash) || hashset_has(pts, [x + 1, y - 1], hash = hash) ? 8 : 0
|
c4 = hashset_has(pts, [x + 1, y], hash = _pt2_hash) || hashset_has(pts, [x + 1, y - 1], hash = _pt2_hash) ? 8 : 0
|
||||||
)
|
)
|
||||||
c1 + c2 + c3 + c4;
|
c1 + c2 + c3 + c4;
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ function _vx_contour(points) =
|
|||||||
// always start from the left-bottom pt
|
// always start from the left-bottom pt
|
||||||
fst = min(points) + [-1, -1]
|
fst = min(points) + [-1, -1]
|
||||||
)
|
)
|
||||||
_vx_contour_travel(hashset(points, hash = function(p) _pt2_hash(p)), fst, fst);
|
_vx_contour_travel(hashset(points, hash = _pt2_hash), fst, fst);
|
||||||
|
|
||||||
_vx_contour_nxt_offset = [
|
_vx_contour_nxt_offset = [
|
||||||
[1, 0], // RIGHT
|
[1, 0], // RIGHT
|
||||||
|
@@ -8,18 +8,19 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../__comm__/_pt2_hash.scad>;
|
|
||||||
use <../__comm__/_pt3_hash.scad>;
|
|
||||||
use <../__comm__/__to2d.scad>;
|
use <../__comm__/__to2d.scad>;
|
||||||
use <../__comm__/__to3d.scad>;
|
use <../__comm__/__to3d.scad>;
|
||||||
use <_impl/_vx_bezier_impl.scad>;
|
use <_impl/_vx_bezier_impl.scad>;
|
||||||
use <../util/dedup.scad>;
|
use <../util/dedup.scad>;
|
||||||
|
|
||||||
|
include <../__comm__/_pt2_hash.scad>;
|
||||||
|
include <../__comm__/_pt3_hash.scad>;
|
||||||
|
|
||||||
function vx_bezier(p1, p2, p3, p4) =
|
function vx_bezier(p1, p2, p3, p4) =
|
||||||
let(
|
let(
|
||||||
is2d = len(p1) == 2,
|
is2d = len(p1) == 2,
|
||||||
pts = is2d ? _vx_bezier2(__to3d(p1), __to3d(p2), __to3d(p3), __to3d(p4), []) :
|
pts = is2d ? _vx_bezier2(__to3d(p1), __to3d(p2), __to3d(p3), __to3d(p4), []) :
|
||||||
_vx_bezier3(p1, p2, p3, p4, []),
|
_vx_bezier3(p1, p2, p3, p4, []),
|
||||||
deduped = dedup(pts, hash = is2d ? function(p) _pt2_hash(p) : function(p) _pt3_hash(p))
|
deduped = dedup(pts, hash = is2d ? _pt2_hash : _pt3_hash)
|
||||||
)
|
)
|
||||||
is2d ? [for(p = deduped) __to2d(p)] : deduped;
|
is2d ? [for(p = deduped) __to2d(p)] : deduped;
|
@@ -8,12 +8,13 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../__comm__/_pt2_hash.scad>;
|
|
||||||
use <_impl/_vx_circle_impl.scad>;
|
use <_impl/_vx_circle_impl.scad>;
|
||||||
use <../util/set/hashset.scad>;
|
use <../util/set/hashset.scad>;
|
||||||
use <../util/set/hashset_elems.scad>;
|
use <../util/set/hashset_elems.scad>;
|
||||||
|
|
||||||
|
include <../__comm__/_pt2_hash.scad>;
|
||||||
|
|
||||||
function vx_circle(radius, filled = false) =
|
function vx_circle(radius, filled = false) =
|
||||||
hashset_elems(
|
hashset_elems(
|
||||||
hashset(_vx_circle_impl(radius, filled), hash = function(p) _pt2_hash(p))
|
hashset(_vx_circle_impl(radius, filled), hash = _pt2_hash)
|
||||||
);
|
);
|
@@ -8,11 +8,12 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../__comm__/_pt2_hash.scad>;
|
|
||||||
use <../__comm__/_pt3_hash.scad>;
|
|
||||||
use <_impl/_vx_curve_impl.scad>;
|
use <_impl/_vx_curve_impl.scad>;
|
||||||
use <../util/dedup.scad>;
|
use <../util/dedup.scad>;
|
||||||
|
|
||||||
|
include <../__comm__/_pt2_hash.scad>;
|
||||||
|
include <../__comm__/_pt3_hash.scad>;
|
||||||
|
|
||||||
function vx_curve(points, tightness = 0) =
|
function vx_curve(points, tightness = 0) =
|
||||||
let(leng = len(points))
|
let(leng = len(points))
|
||||||
dedup([
|
dedup([
|
||||||
@@ -24,4 +25,4 @@ function vx_curve(points, tightness = 0) =
|
|||||||
for(i = [0:len(pts) - 2]) pts[i]
|
for(i = [0:len(pts) - 2]) pts[i]
|
||||||
],
|
],
|
||||||
points[leng - 2]
|
points[leng - 2]
|
||||||
], hash = len(points[0]) == 2 ? function(p) _pt2_hash(p) : function(p) _pt3_hash(p));
|
], hash = len(points[0]) == 2 ? _pt2_hash : _pt3_hash);
|
@@ -10,11 +10,9 @@
|
|||||||
|
|
||||||
use <../util/set/hashset.scad>;
|
use <../util/set/hashset.scad>;
|
||||||
use <../util/set/hashset_has.scad>;
|
use <../util/set/hashset_has.scad>;
|
||||||
use <../__comm__/_pt3_hash.scad>;
|
|
||||||
|
include <../__comm__/_pt3_hash.scad>;
|
||||||
|
|
||||||
function vx_difference(points1, points2) =
|
function vx_difference(points1, points2) =
|
||||||
let(
|
let(set = hashset(points2, hash = _pt3_hash))
|
||||||
hash = function(p) _pt3_hash(p),
|
[for(p = points1) if(!hashset_has(set, p, hash = _pt3_hash)) p];
|
||||||
set = hashset(points2, hash = hash)
|
|
||||||
)
|
|
||||||
[for(p = points1) if(!hashset_has(set, p, hash = hash)) p];
|
|
@@ -10,14 +10,14 @@
|
|||||||
|
|
||||||
use <../util/set/hashset.scad>;
|
use <../util/set/hashset.scad>;
|
||||||
use <../util/set/hashset_has.scad>;
|
use <../util/set/hashset_has.scad>;
|
||||||
use <../__comm__/_pt3_hash.scad>;
|
|
||||||
|
include <../__comm__/_pt3_hash.scad>;
|
||||||
|
|
||||||
function vx_intersection(points1, points2) =
|
function vx_intersection(points1, points2) =
|
||||||
let(
|
let(
|
||||||
leng1 = len(points1),
|
leng1 = len(points1),
|
||||||
leng2 = len(points2),
|
leng2 = len(points2),
|
||||||
pts_pair = leng1 > leng2 ? [points1, points2] : [points2, points1],
|
pts_pair = leng1 > leng2 ? [points1, points2] : [points2, points1],
|
||||||
hash = function(p) _pt3_hash(p),
|
set = hashset(pts_pair[1], hash = _pt3_hash)
|
||||||
set = hashset(pts_pair[1], hash = hash)
|
|
||||||
)
|
)
|
||||||
[for(p = pts_pair[0]) if(hashset_has(set, p, hash = hash)) p];
|
[for(p = pts_pair[0]) if(hashset_has(set, p, hash = _pt3_hash)) p];
|
@@ -1,10 +1,11 @@
|
|||||||
use <../__comm__/_pt2_hash.scad>;
|
|
||||||
use <../in_shape.scad>;
|
use <../in_shape.scad>;
|
||||||
use <../util/sorted.scad>;
|
use <../util/sorted.scad>;
|
||||||
use <vx_polyline.scad>;
|
use <vx_polyline.scad>;
|
||||||
use <../util/set/hashset.scad>;
|
use <../util/set/hashset.scad>;
|
||||||
use <../util/set/hashset_elems.scad>;
|
use <../util/set/hashset_elems.scad>;
|
||||||
|
|
||||||
|
include <../__comm__/_pt2_hash.scad>;
|
||||||
|
|
||||||
function vx_polygon(points, filled = false) =
|
function vx_polygon(points, filled = false) =
|
||||||
let(contour = vx_polyline([each points, points[0]]))
|
let(contour = vx_polyline([each points, points[0]]))
|
||||||
!filled ? contour :
|
!filled ? contour :
|
||||||
@@ -29,5 +30,5 @@ function vx_polygon(points, filled = false) =
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
hashset_elems(
|
hashset_elems(
|
||||||
hashset(all, hash = function(p) _pt2_hash(p))
|
hashset(all, hash = _pt2_hash)
|
||||||
);
|
);
|
@@ -11,11 +11,12 @@
|
|||||||
use <../__comm__/__to3d.scad>;
|
use <../__comm__/__to3d.scad>;
|
||||||
use <../__comm__/__to2d.scad>;
|
use <../__comm__/__to2d.scad>;
|
||||||
use <../__comm__/__lines_from.scad>;
|
use <../__comm__/__lines_from.scad>;
|
||||||
use <../__comm__/_pt2_hash.scad>;
|
|
||||||
use <../__comm__/_pt3_hash.scad>;
|
|
||||||
use <../util/dedup.scad>;
|
use <../util/dedup.scad>;
|
||||||
use <vx_line.scad>;
|
use <vx_line.scad>;
|
||||||
|
|
||||||
|
include <../__comm__/_pt2_hash.scad>;
|
||||||
|
include <../__comm__/_pt3_hash.scad>;
|
||||||
|
|
||||||
function vx_polyline(points) =
|
function vx_polyline(points) =
|
||||||
let(
|
let(
|
||||||
is_2d = len(points[0]) == 2,
|
is_2d = len(points[0]) == 2,
|
||||||
@@ -24,5 +25,5 @@ function vx_polyline(points) =
|
|||||||
)
|
)
|
||||||
dedup(
|
dedup(
|
||||||
is_2d ? [for(pt = polyline) __to2d(pt)] : polyline,
|
is_2d ? [for(pt = polyline) __to2d(pt)] : polyline,
|
||||||
hash = is_2d ? function(p) _pt2_hash(p) : function(p) _pt3_hash(p)
|
hash = is_2d ? _pt2_hash : _pt3_hash
|
||||||
);
|
);
|
@@ -8,11 +8,12 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
use <../__comm__/_pt3_hash.scad>;
|
|
||||||
use <../util/set/hashset.scad>;
|
use <../util/set/hashset.scad>;
|
||||||
use <../util/set/hashset_elems.scad>;
|
use <../util/set/hashset_elems.scad>;
|
||||||
|
|
||||||
|
include <../__comm__/_pt3_hash.scad>;
|
||||||
|
|
||||||
function vx_union(points1, points2) =
|
function vx_union(points1, points2) =
|
||||||
hashset_elems(
|
hashset_elems(
|
||||||
hashset(concat(points1, points2), hash = function(p) _pt3_hash(p))
|
hashset(concat(points1, points2), hash = _pt3_hash)
|
||||||
);
|
);
|
Reference in New Issue
Block a user