1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-04-21 22:51:59 +02:00

use delaunay to voronoi

This commit is contained in:
Justin Lin 2021-04-24 11:57:45 +08:00
parent 90c0552c19
commit 53c82c6308
2 changed files with 2 additions and 41 deletions

View File

@ -1,23 +0,0 @@
use <../../ptf/ptf_rotate.scad>;
function _default_region_size(points) =
let(
xs = [for(p = points) p[0]],
ys = [for(p = points) abs(p[1])]
)
max([max(xs) - min(xs), max(ys) - min(ys)]);
function _cells_lt_before_intersection(shape, size, points, pt, half_region_size) =
[
for(p = points)
if(pt != p)
let(
v = p - pt,
offset = (pt + p) / 2 - v / norm(v) * half_region_size,
a = atan2(v[1], v[0])
)
[
for(sp = shape)
ptf_rotate(sp, a) + offset
]
];

View File

@ -8,22 +8,6 @@
*
**/
use <../triangle/tri_delaunay.scad>;
use <_impl/_vrn2_cells_from_impl.scad>;
use <_impl/_convex_intersection_for.scad>;
use <../shape_square.scad>;
function vrn2_cells_from(points) =
let(
size = _default_region_size(points),
half_size = size * 0.5,
shape = shape_square(size),
regions_lt = [
for(p = points)
_cells_lt_before_intersection(shape, size, points, p, half_size)
]
)
[
for(regions = regions_lt)
_convex_intersection_for(regions)
];
function vrn2_cells_from(points) = tri_delaunay(points, ret = "VORONOI_CELLS");