From 99e91aafaae1d1f3e4f9643d8bdba9a93b67c6c9 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 5 Jun 2019 09:34:24 +0800 Subject: [PATCH] update space_size --- docs/lib-vorono3d.md | 2 +- src/voronoi3d.scad | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/lib-vorono3d.md b/docs/lib-vorono3d.md index f9eacd16..30b37be1 100644 --- a/docs/lib-vorono3d.md +++ b/docs/lib-vorono3d.md @@ -6,7 +6,7 @@ Creats a 3D version of [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_d ys = [for(p = points) abs(p[1])]; zs = [for(p = points) abs(p[2])]; space_size = max([(max(xs) - min(xs) / 2), (max(ys) - min(ys)) / 2, (max(zs) - min(zs)) / 2]); - // cube([space_size, space_size * 2, space_size * 3]); + // cube([space_size, space_size * 2, space_size * 2]); The preview or rendering of 3D Voronoi is slow. If you want to use this module, render and export the 3D Voronoi model first. Then, `import` the model to do what you want. diff --git a/src/voronoi3d.scad b/src/voronoi3d.scad index 47e93aa4..007a886f 100644 --- a/src/voronoi3d.scad +++ b/src/voronoi3d.scad @@ -7,7 +7,7 @@ module voronoi3d(points, space_size = "auto", spacing = 1) { ys = [for(p = points) abs(p[1])]; zs = [for(p = points) abs(p[2])]; - space_size = max([(max(xs) - min(xs) / 2), (max(ys) - min(ys)) / 2, (max(zs) - min(zs)) / 2]); + space_size = max([max(xs) - min(xs), max(ys) - min(ys), max(zs) - min(zs)]); half_space_size = 0.5 * space_size; offset_leng = spacing * 0.5 + half_space_size; @@ -21,7 +21,7 @@ module voronoi3d(points, space_size = "auto", spacing = 1) { translate((pt + p) / 2 - normalize(v) * offset_leng) rotate([0, -ryz[0], ryz[1]]) - cube([space_size, space_size * 2, space_size * 3], center = true); + cube([space_size, space_size * 2, space_size * 2], center = true); } } }