Created
December 8, 2022 07:45
-
-
Save acgetchell/9e458eb5e459df17e94e713e69e7026e to your computer and use it in GitHub Desktop.
Rust Delaunay triangulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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