MCPcopy Create free account
hub / github.com/Notgnoshi/generative / triangulate

Function triangulate

generative/triangulation.rs:7–23  ·  view source on GitHub ↗

Calculate the Delaunay triangulation of the given point cloud

(points: impl Iterator<Item = geo::Point>)

Source from the content-addressed store, hash-verified

5
6/// Calculate the Delaunay triangulation of the given point cloud
7pub fn triangulate(points: impl Iterator<Item = geo::Point>) -> Option<Triangulation> {
8 let points: Vec<delaunator::Point> = points
9 .map(|gp| delaunator::Point {
10 x: gp.x(),
11 y: gp.y(),
12 })
13 .collect();
14 if points.len() < 3 {
15 return None;
16 }
17 let triangulation = delaunator::triangulate(&points);
18
19 Some(Triangulation {
20 points,
21 triangulation,
22 })
23}
24
25pub struct Triangulation {
26 points: Vec<delaunator::Point>,

Callers 5

mainFunction · 0.85
mainFunction · 0.85
test_graphFunction · 0.85
test_urquhartFunction · 0.85

Calls

no outgoing calls

Tested by 3

test_graphFunction · 0.68
test_urquhartFunction · 0.68