diff --git a/src/util/dedup.scad b/src/util/dedup.scad index 65fc0533..56d3236f 100644 --- a/src/util/dedup.scad +++ b/src/util/dedup.scad @@ -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]]; diff --git a/src/voronoi/_impl/_convex_intersection.scad b/src/voronoi/_impl/_convex_intersection.scad index 9c9b5147..bf77c67c 100644 --- a/src/voronoi/_impl/_convex_intersection.scad +++ b/src/voronoi/_impl/_convex_intersection.scad @@ -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( diff --git a/src/voronoi/vrn2_cells_space.scad b/src/voronoi/vrn2_cells_space.scad index 7af04c84..ac7c0cd8 100644 --- a/src/voronoi/vrn2_cells_space.scad +++ b/src/voronoi/vrn2_cells_space.scad @@ -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]] ) )