diff --git a/README.md b/README.md index 743ceba2..65d00155 100644 --- a/README.md +++ b/README.md @@ -236,7 +236,7 @@ See [examples](examples). ### Voronoi - [voronoi/vrn2_from](https://openhome.cc/eGossip/OpenSCAD/lib2x-vrn2_from.html) - voronoi/vrn2_space -- voronoi/vrn2_cells_from +- [voronoi/vrn2_cells_from](https://openhome.cc/eGossip/OpenSCAD/lib2x-vrn2_cells_from.html) - voronoi/vrn2_cells_space - voronoi/vrn3_from - voronoi/vrn3_space diff --git a/docs/images/lib2x-vrn2_cells_from-1.JPG b/docs/images/lib2x-vrn2_cells_from-1.JPG new file mode 100644 index 00000000..d37bdc09 Binary files /dev/null and b/docs/images/lib2x-vrn2_cells_from-1.JPG differ diff --git a/docs/lib2x-vrn2_cells_from.md b/docs/lib2x-vrn2_cells_from.md new file mode 100644 index 00000000..989df5bf --- /dev/null +++ b/docs/lib2x-vrn2_cells_from.md @@ -0,0 +1,35 @@ +# vrn2_cells_from + +Creats Voronoi shapes from a list of points. + +**Since:** 2.4 + +## Parameters + +- `points` : Points for each cell. + +## Examples + + use ; + use ; + + xs1 = rands(-20, 20, 15); + ys1 = rands(-20, 20, 15); + points = [for(i = [0:len(xs1) - 1]) [xs1[i], ys1[i]]]; + + cells = vrn2_cells_from(points); + for(i = [0:len(points) - 1]) { + pt = points[i]; + cell = cells[i]; + + linear_extrude(1) + hull_polyline2d(concat(cell, [cell[0]]), width = 1); + + color(rands(0, 1, 3)) + translate(pt) + linear_extrude(2, scale = 0.8) + translate(-pt) + polygon(cell); + } + +![vrn2_cells_from](images/lib2x-vrn2_cells_from-1.JPG) diff --git a/src/voronoi/vrn2_cells_from.scad b/src/voronoi/vrn2_cells_from.scad index 144c6615..7b85e162 100644 --- a/src/voronoi/vrn2_cells_from.scad +++ b/src/voronoi/vrn2_cells_from.scad @@ -1,3 +1,14 @@ +/** +* vrn2_cells_from.scad +* +* @copyright Justin Lin, 2020 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-vrn2_cells_from.html +* +**/ + + use <_impl/_vrn2_cells_from_impl.scad>; use <_impl/_convex_intersection_for.scad>; use <../shape_square.scad>;