Skip to content

Instantly share code, notes, and snippets.

@acgetchell
Created December 8, 2022 07:45
Show Gist options
  • Save acgetchell/9e458eb5e459df17e94e713e69e7026e to your computer and use it in GitHub Desktop.
Save acgetchell/9e458eb5e459df17e94e713e69e7026e to your computer and use it in GitHub Desktop.
Rust Delaunay triangulation
extern crate delaunator;
use delaunator::{Point, delaunay};
fn main() {
// Define a set of points
let points = vec![
Point { x: 0.0, y: 0.0 },
Point { x: 1.0, y: 0.0 },
Point { x: 1.0, y: 1.0 },
Point { x: 0.0, y: 1.0 },
Point { x: 0.5, y: 0.5 },
];
// Generate the Delaunay triangulation
let triangulation = delaunay(&points);
// Print the triangulation as a list of triangles
for triangle in triangulation.triangles() {
println!("{:?}", triangle);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment