diff --git a/README.md b/README.md index c4dc0be8..e576a451 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ See [examples](examples). - [voronoi/vrn2_from](https://openhome.cc/eGossip/OpenSCAD/lib2x-vrn2_from.html) - [voronoi/vrn2_space](https://openhome.cc/eGossip/OpenSCAD/lib2x-vrn2_space.html) - [voronoi/vrn2_cells_from](https://openhome.cc/eGossip/OpenSCAD/lib2x-vrn2_cells_from.html) -- voronoi/vrn2_cells_space +- [voronoi/vrn2_cells_space](https://openhome.cc/eGossip/OpenSCAD/lib2x-vrn2_cells_space.html) - voronoi/vrn3_from - voronoi/vrn3_space diff --git a/docs/images/lib2x-vrn2_cells_space-1.JPG b/docs/images/lib2x-vrn2_cells_space-1.JPG new file mode 100644 index 00000000..faeae757 Binary files /dev/null and b/docs/images/lib2x-vrn2_cells_space-1.JPG differ diff --git a/docs/images/lib2x-vrn2_cells_space-2.JPG b/docs/images/lib2x-vrn2_cells_space-2.JPG new file mode 100644 index 00000000..f420ddc4 Binary files /dev/null and b/docs/images/lib2x-vrn2_cells_space-2.JPG differ diff --git a/docs/lib2x-vrn2_cells_space.md b/docs/lib2x-vrn2_cells_space.md new file mode 100644 index 00000000..98ed4992 --- /dev/null +++ b/docs/lib2x-vrn2_cells_space.md @@ -0,0 +1,54 @@ +# vrn2_cells_space + +Creats cell shapes of Voronoi in the first quadrant. You specify a space and a grid width. The center of each cell will be distributed in each grid randomly. + +**Since:** 2.4 + +## Parameters + +- `size` : 2 value array [x, y], rectangle with dimensions x and y. +- `grid_w` : The width of each grid. If it can split `size` equally, the voronoi diagram is seamless at the junction of top-bottom and left-right. +- `seed` : Seed value for random number generator for repeatable results. + +## Examples + + use ; + use ; + + size = [20, 20]; + grid_w = 5; + cells = vrn2_cells_space(size, grid_w); + + for(cell = cells) { + cell_pt = cell[0]; + cell_poly = cell[1]; + + linear_extrude(1) + hull_polyline2d(concat(cell_poly, [cell_poly[0]]), width = 1); + + color(rands(0, 1, 3)) + translate(cell_pt) + linear_extrude(2, scale = 0.8) + translate(-cell_pt) + polygon(cell_poly); + } + +![vrn2_cells_space](images/lib2x-vrn2_cells_space-1.JPG) + + use ; + use ; + use ; + + size = [40, 80]; + grid_w = 5; + cells = vrn2_cells_space(size, grid_w); + + $fn = 4; + + for(cell = cells) { + cell_poly = [for(p = cell[1]) ptf_torus(size, p, [10, 5], [360, 360])]; + + hull_polyline3d(cell_poly, thickness = 1); + } + +![vrn2_cells_space](images/lib2x-vrn2_cells_space-2.JPG) \ No newline at end of file