delaunay2d

Crates.iodelaunay2d
lib.rsdelaunay2d
version0.0.2
sourcesrc
created_at2017-01-18 03:20:27.278885
updated_at2017-12-13 01:36:16.290597
descriptionA library to compute Delaunay triangulations and Voronoi diagrams in 2D space
homepage
repositoryhttps://github.com/mdsherry/delaunay2d
max_upload_size
id8114
size25,300
(mdsherry)

documentation

README

% Delaunay2D

This crate provides a library for computing a Delaunay triangulation from a set of points using the Bowyer–Watson algorithm.

While performance shouldn't be terrible, there is definite room for improvement.

Usage

extern crate delaunay2d;

Example: Delaunay triangulation

use delaunay2d::{Delaunay2D, Triangle};
let mut dt = Delaunay2D::new((0., 0.), 9999.);

dt.add_point((13., 12.));
dt.add_point((18., 19.));
dt.add_point((21., 5.));
dt.add_point((37., -3.));

let mut triangles = dt.export_triangles();
triangles.sort_by_key(|t| (t.0, t.1, t.2));
assert_eq!(vec![Triangle(2,1,0), Triangle(3, 1, 2)], triangles);

Example: Voronoi regions

use delaunay2d::{Delaunay2D};
let mut dt = Delaunay2D::new((0., 0.), 9999.);

dt.add_point((13., 12.));
dt.add_point((18., 19.));
dt.add_point((21., 5.));
dt.add_point((37., -3.));

let (points, mut regions) = dt.export_voronoi_regions();
regions.sort();
assert_eq!(10, points.len());
assert_eq!(4, regions.len());
Commit count: 7

cargo fmt