1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-03-14 02:59:42 +01:00
This commit is contained in:
Justin Lin 2019-06-07 17:46:17 +08:00
parent 43a52bbaa0
commit 810a1d3ece
4 changed files with 8 additions and 8 deletions

View File

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View File

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -1,4 +1,4 @@
# voronoi
# voronoi2d
Creats a [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_diagram). The initial region for each cell is calculated automatically from the given points by the following code:
@ -17,20 +17,20 @@ Creats a [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_diagram). The i
## Examples
include <voronoi.scad>;
include <voronoi2d.scad>;
xs = rands(-20, 20, 50);
ys = rands(-20, 20, 50);
points = [for(i = [0:len(xs) - 1]) [xs[i], ys[i]]];
voronoi(points);
voronoi2d(points);
translate([60, 0, 0])
voronoi(points, region_type = "circle");
![voronoi](images/lib-voronoi-1.JPG)
![voronoi2d](images/lib-voronoi2d-1.JPG)
include <voronoi.scad>;
include <voronoi2d.scad>;
include <hollow_out.scad>;
xs = rands(0, 40, 50);
@ -40,8 +40,8 @@ Creats a [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_diagram). The i
difference() {
square([40, 20]);
voronoi(points);
voronoi2d(points);
}
hollow_out(shell_thickness = 1) square([40, 20]);
![voronoi](images/lib-voronoi-2.JPG)
![voronoi2d](images/lib-voronoi2d-2.JPG)

View File

@ -1,4 +1,4 @@
module voronoi(points, spacing = 1, r = 0, delta = 0, chamfer = false, region_type = "square") {
module voronoi2d(points, spacing = 1, r = 0, delta = 0, chamfer = false, region_type = "square") {
xs = [for(p = points) p[0]];
ys = [for(p = points) abs(p[1])];