Crates.io | delaunay2d |
lib.rs | delaunay2d |
version | 0.0.2 |
source | src |
created_at | 2017-01-18 03:20:27.278885 |
updated_at | 2017-12-13 01:36:16.290597 |
description | A library to compute Delaunay triangulations and Voronoi diagrams in 2D space |
homepage | |
repository | https://github.com/mdsherry/delaunay2d |
max_upload_size | |
id | 8114 |
size | 25,300 |
% 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.
extern crate delaunay2d;
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);
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());