#voronoi #geometry #sweepline

nightly bin+lib boostvoronoi

Boost voronoi ported to 100% rust

5 releases

new 0.8.4 Jun 8, 2021
0.8.1 Apr 11, 2021
0.7.0 Mar 25, 2021

#45 in Math

Download history 23/week @ 2021-02-23 78/week @ 2021-03-02 41/week @ 2021-03-09 27/week @ 2021-03-16 40/week @ 2021-03-23 26/week @ 2021-03-30 51/week @ 2021-04-06 83/week @ 2021-04-13 35/week @ 2021-04-20 3/week @ 2021-04-27 2/week @ 2021-05-04 12/week @ 2021-05-11 32/week @ 2021-05-18 32/week @ 2021-05-25 9/week @ 2021-06-01 81/week @ 2021-06-08

133 downloads per month
Used in 2 crates

BSL-1.0 license

11K SLoC

Crates.io Documentation Workflow Workflow dependency status

Segmented Voronoi for Rust

Rusty voronoi

Boost 1.75.0 polygon::voronoi ported to 100% rust (nothing voronoi related changed in 1.76) This implementation of Fortune's algorithm works on line segments as well as points, making it useful for calculating centerlines (like the image above).

Code still in development, not ready for any purpose.


The code uses #![feature(map_first_last)] i.e. rust nightly.

Rusty voronoi

Gui example:

cargo run --example fltk_gui
  • Mouse click to place new points.
  • Press and hold 'L' + mouse click to add single line.
  • Press and hold 'S' + mouse click to add strings of lines.
  • Use mouse wheel to zoom.
  • Mouse click and drag to pan.

API example:

use boostvoronoi::{Point,Line};
use boostvoronoi::builder::{Builder};
type I1 = i32; // this is the integer input type
type F1 = f64; // this is the float output type (circle event coordinates)

// Only unique Points will be used. Points should not intersect lines
let p = vec![Point{x:9_i32, y:10}];
// Lines may only intersect at the endpoints.
let s = vec![Line::new(Point{x:10_i32, y:11}, Point{x:12, y:13})];
let mut vb = Builder::<I1, F1>::new();

// you will have to keep track of the input geometry. it will be referenced as
// input geometry indices in the output.

// this will generate the list of cells, edges and circle events (aka vertices)
let result = vb.construct().unwrap();

Edges may become curves when line segments are used as input, see the example code for discretization and interpolation.


  • Fix the degenerate vertex key problem
  • Fix the beach-line key problem
  • Error handling
  • Evaluate the generic API. Is <I1, F1, I2, F2> really needed?
  • Replace Verify the builtin ulp implementation
  • Replace num::BigInt with something lighter
  • Add many more test cases for voronoi_robust_ftp.rs, specially for ulp
  • Remove use of vec_map::VecMap where not absolutely needed.
  • Benchmark and optimize
  • Example GUI with more features. fltk?
  • Fix the beach-line bug found with main.rs example

All credit goes to the original author (Andrii Sydorchuk) and the boost contributors, except the porting mistakes. They are all mine.


~43K SLoC