Voronoice

A nice and fast way to construct 2D Voronoi diagrams written in Rust.

Voronoice builds Voronoi diagrams by first obtaining its Delauney triangulation, through the really fast delaunator crate and then extracting its dual Voronoi diagram.

Example

```rust use voronoice::*;

// voronoi sites let sites = vec![ Point { x: 0.0, y: 0.0 }, Point { x: 1.0, y: 0.0 }, Point { x: 0.0, y: 1.0 } ];

// builds a voronoi diagram from the set of sites above, bounded by a square of size 4 let myvoronoi = VoronoiBuilder::default() .setsites(sites) .setboundingbox(BoundingBox::newcenteredsquare(4.0)) .setlloydrelaxation_iterations(5) .build() .unwrap();

// inspect cells through iterators myvoronoi.itercells().for_each(|cell| { println!("Vertices of cell: {:?}", cell.vertices().collect::>()) });

// or proble cells individually let mycell = myvoronoi.cell(1); println!("Second cell has site {:?}, voronoi vertices {:?} and delauney triangles {:?}", mycell.siteposition(), mycell.vertices().collect::>(), mycell.triangles().collect::>());

// or, for graphical applications, that benefit from index buffers // you can access the raw, indexed data let allvoronoicellvertices = myvoronoi.vertices(); let indexedvoronoicells = myvoronoi.cells(); println!("The first vertex position for the first voronoi cell is at {:?}", allvoronoicellvertices[indexedvoronoicells[0][0]]); ```

Documentation

On docs.rs.

Performance

Here are some generation times on a 3.5GHz Core i7 from 2012.

| Number of points | Time | | -----------------|--------------| | 1,000 | 190 µs | | 10,000 | 2 ms | | 100,000 | 23 ms | | 1,000,000 | 402 ms | | 5,000,000 | 2.4 s | | 10,000,000 | 5.1 s |