Skip to content

Commit

Permalink
bugfix SimplePolygon diameter sqrt
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenGar committed Mar 21, 2024
1 parent bc0083f commit 13a2f16
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions jagua-rs/src/geometry/primitives/simple_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,14 @@ impl SimplePolygon {
let ch = convex_hull_from_points(points);

//go through all pairs of points and find the pair with the largest distance
ch.iter()
let sq_diam = ch
.iter()
.tuple_combinations()
.map(|(p1, p2)| p1.sq_distance(p2))
.max_by_key(|d| NotNan::new(*d).unwrap())
.expect("convex hull is empty")
.into()
.max_by_key(|sq_d| NotNan::new(*sq_d).unwrap())
.expect("convex hull is empty");

sq_diam.sqrt()
}

pub fn generate_bounding_box(points: &[Point]) -> AARectangle {
Expand Down

0 comments on commit 13a2f16

Please sign in to comment.