1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-01 04:20:27 +02:00
This commit is contained in:
Justin Lin
2022-03-12 09:37:57 +08:00
parent 52b5a26006
commit e5aff6782d
3 changed files with 7 additions and 7 deletions

View File

@@ -19,7 +19,6 @@ function dedup(lt, eq = function(e1, e2) e1 == e2, hash = function(e) _str_hash(
b_numbers = is_undef(number_of_buckets) ? ceil(sqrt(leng_lt)) : number_of_buckets,
buckets = [for(i = [0:b_numbers - 1]) []],
deduped = _dedup(lt, leng_lt, buckets, eq, hash, b_numbers),
i_elem_lt = [for(bucket = deduped) each bucket],
sorted = sort(i_elem_lt, by = function(e1, e2) e1[0] - e2[0])
sorted = sort([for(bucket = deduped) each bucket], by = function(e1, e2) e1[0] - e2[0])
)
[for(i_elem = sorted) i_elem[1]];

View File

@@ -4,9 +4,10 @@ use <../../lines_intersection.scad>;
use <_convex_ct_clk_order.scad>;
function _in_convex_r(i, j, preC, convex_pts, pt, leng, convex_pts, pt) =
j == leng ? true :
j == leng || (
let(c = cross(convex_pts[i] - pt, convex_pts[j] - pt))
c * preC <= 0 ? false : _in_convex_r(j, j + 1, c, convex_pts, pt, leng, convex_pts, pt) ;
c * preC > 0 && _in_convex_r(j, j + 1, c, convex_pts, pt, leng, convex_pts, pt)
);
function _in_convex(convex_pts, pt) =
let(

View File

@@ -20,8 +20,8 @@ function vrn2_cells_space(size, grid_w, seed) =
shape = shape_square(grid_w * 3),
gw = size.x / grid_w,
gh = size.y / grid_w,
cell_nbrs_lt = [for(cy = [-grid_w:grid_w:size.y])
for(cx = [-grid_w:grid_w:size.x])
cell_nbrs_lt = [
for(cy = [-grid_w:grid_w:size.y], cx = [-grid_w:grid_w:size.x])
let(
nbrs = _neighbors(
[floor(cx / grid_w), floor(cy / grid_w)],
@@ -32,7 +32,7 @@ function vrn2_cells_space(size, grid_w, seed) =
),
p = nbrs[4],
points = concat(
[for(i = [0:3]) nbrs[i]],
[nbrs[0], nbrs[1], nbrs[2], nbrs[3]],
[for(i = [5:len(nbrs) - 1]) nbrs[i]]
)
)