1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-07 07:16:36 +02:00
This commit is contained in:
Justin Lin
2020-04-03 17:40:27 +08:00
parent fe6b207e91
commit 72b3bcab2e
2 changed files with 3 additions and 4 deletions

View File

@@ -1,4 +1,3 @@
use <ptf/ptf_rotate.scad>; use <ptf/ptf_rotate.scad>;
function _default_region_size(points) = function _default_region_size(points) =
@@ -8,8 +7,7 @@ function _default_region_size(points) =
) )
max([(max(xs) - min(xs) / 2), (max(ys) - min(ys)) / 2]); max([(max(xs) - min(xs) / 2), (max(ys) - min(ys)) / 2]);
function _cells_lt_before_intersection(shape, size, points, pt) = function _cells_lt_before_intersection(shape, size, points, pt, half_region_size) =
let(half_region_size = 0.5 * size)
[ [
for(p = points) for(p = points)
if(pt != p) if(pt != p)

View File

@@ -5,10 +5,11 @@ use <shape_square.scad>;
function voronoi_cells(points) = function voronoi_cells(points) =
let( let(
size = _default_region_size(points), size = _default_region_size(points),
half_size = size * 0.5,
shape = shape_square(size), shape = shape_square(size),
regions_lt = [ regions_lt = [
for(p = points) for(p = points)
_cells_lt_before_intersection(shape, size, points, p) _cells_lt_before_intersection(shape, size, points, p, half_size)
] ]
) )
[ [