diff --git a/README.md b/README.md index f594e05a..743ceba2 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,7 @@ See [examples](examples). - [matrix/m_determinant](https://openhome.cc/eGossip/OpenSCAD/lib2x-m_determinant.html) ### Voronoi -- voronoi/vrn2_from +- [voronoi/vrn2_from](https://openhome.cc/eGossip/OpenSCAD/lib2x-vrn2_from.html) - voronoi/vrn2_space - voronoi/vrn2_cells_from - voronoi/vrn2_cells_space diff --git a/docs/images/lib2x-vrn2_from-1.JPG b/docs/images/lib2x-vrn2_from-1.JPG new file mode 100644 index 00000000..a995d82b Binary files /dev/null and b/docs/images/lib2x-vrn2_from-1.JPG differ diff --git a/docs/images/lib2x-vrn2_from-2.JPG b/docs/images/lib2x-vrn2_from-2.JPG new file mode 100644 index 00000000..fa070606 Binary files /dev/null and b/docs/images/lib2x-vrn2_from-2.JPG differ diff --git a/docs/lib2x-vrn2_from.md b/docs/lib2x-vrn2_from.md new file mode 100644 index 00000000..e8c3d258 --- /dev/null +++ b/docs/lib2x-vrn2_from.md @@ -0,0 +1,40 @@ +# vrn2_from + +Creats a [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_diagram) from a list of points. + +**Since:** 2.4 + +## Parameters + +- `points` : Points for each cell. +- `spacing` : Distance between cells. Default to 1. +- `r`, `delta`, `chamfer` : The outlines of each cell can be moved outward or inward. These parameters have the same effect as [`offset`](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#offset). +- `region_type` : The initial shape for each cell can be `"square"` or `"circle"`. Default to `"square"`. + +## Examples + + use ; + + points = [for(i = [0:50]) rands(-20, 20, 2)]; + + vrn2_from(points); + translate([60, 0, 0]) + vrn2_from(points, region_type = "circle"); + +![vrn2_from](images/lib2x-vrn2_from-1.JPG) + + use ; + use ; + + xs = rands(0, 40, 50); + ys = rands(0, 20, 50); + + points = [for(i = [0:len(xs) - 1]) [xs[i], ys[i]]]; + + difference() { + square([40, 20]); + vrn2_from(points); + } + hollow_out(shell_thickness = 1) square([40, 20]); + +![vrn2_from](images/lib2x-vrn2_from-2.JPG) \ No newline at end of file