1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/docs/lib3x-vrn2_from.md

40 lines
1.1 KiB
Markdown
Raw Normal View History

2020-06-17 21:07:40 +08:00
# vrn2_from
2020-11-04 13:15:31 +08:00
Create a [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_diagram) from a list of points.
2020-06-17 21:07:40 +08:00
**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
2022-06-06 13:11:46 +08:00
use <voronoi/vrn2_from.scad>
2020-06-17 21:07:40 +08:00
points = [for(i = [0:50]) rands(-20, 20, 2)];
vrn2_from(points);
2022-05-07 12:26:22 +08:00
translate([80, 0, 0])
2020-06-17 21:07:40 +08:00
vrn2_from(points, region_type = "circle");
2021-02-24 21:09:54 +08:00
![vrn2_from](images/lib3x-vrn2_from-1.JPG)
2020-06-17 21:07:40 +08:00
2022-06-06 13:11:46 +08:00
use <voronoi/vrn2_from.scad>
use <hollow_out.scad>
2020-06-17 21:07:40 +08:00
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]);
2021-02-24 21:09:54 +08:00
![vrn2_from](images/lib3x-vrn2_from-2.JPG)