2021-05-15 09:33:25 +08:00
|
|
|
# tri_delaunay_voronoi
|
|
|
|
|
|
|
|
A method of [`tri_delaunay`](lib3x-tri_delaunay.html). Returns voronoi cells from a delaunay object.
|
|
|
|
|
|
|
|
**Since:** 3.0
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
- `d` : A delaunay object.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2022-06-06 13:11:46 +08:00
|
|
|
use <triangle/tri_delaunay.scad>
|
|
|
|
use <triangle/tri_delaunay_indices.scad>
|
|
|
|
use <triangle/tri_delaunay_shapes.scad>
|
|
|
|
use <triangle/tri_delaunay_voronoi.scad>
|
|
|
|
use <polyline_join.scad>
|
2021-05-15 09:33:25 +08:00
|
|
|
|
|
|
|
points = [for(i = [0:20]) rands(-100, 100, 2)];
|
|
|
|
|
|
|
|
delaunay = tri_delaunay(points, ret = "DELAUNAY");
|
|
|
|
|
|
|
|
tris = [for(ti = tri_delaunay_indices(delaunay)) [for(i = ti) points[i]]];
|
|
|
|
linear_extrude(1)
|
|
|
|
for(t = tris) {
|
|
|
|
polygon(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
color("black")
|
|
|
|
linear_extrude(2)
|
|
|
|
for(t = tri_delaunay_shapes(delaunay)) {
|
|
|
|
offset(-1)
|
|
|
|
polygon(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
color("red")
|
|
|
|
linear_extrude(3)
|
|
|
|
for(t = tri_delaunay_voronoi(delaunay)) {
|
2022-02-27 22:32:57 +08:00
|
|
|
polyline_join([each t, t[0]])
|
2021-12-04 10:57:29 +08:00
|
|
|
circle(1);
|
2021-05-15 09:33:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
![tri_delaunay_voronoi](images/lib3x-tri_delaunay_voronoi-1.JPG)
|