1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-07 15:26:39 +02: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: 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 ## Examples
include <voronoi.scad>; include <voronoi2d.scad>;
xs = rands(-20, 20, 50); xs = rands(-20, 20, 50);
ys = rands(-20, 20, 50); ys = rands(-20, 20, 50);
points = [for(i = [0:len(xs) - 1]) [xs[i], ys[i]]]; points = [for(i = [0:len(xs) - 1]) [xs[i], ys[i]]];
voronoi(points); voronoi2d(points);
translate([60, 0, 0]) translate([60, 0, 0])
voronoi(points, region_type = "circle"); 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>; include <hollow_out.scad>;
xs = rands(0, 40, 50); xs = rands(0, 40, 50);
@@ -40,8 +40,8 @@ Creats a [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_diagram). The i
difference() { difference() {
square([40, 20]); square([40, 20]);
voronoi(points); voronoi2d(points);
} }
hollow_out(shell_thickness = 1) square([40, 20]); 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]]; xs = [for(p = points) p[0]];
ys = [for(p = points) abs(p[1])]; ys = [for(p = points) abs(p[1])];