Skip to content

Commit

Permalink
Ensure points passed to convex polygon aren't empty
Browse files Browse the repository at this point in the history
  • Loading branch information
hakolao committed Oct 13, 2023
1 parent 76c7b57 commit 790016d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/shape/convex_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ impl ConvexPolygon {
/// Convexity of the input polyline is not checked.
/// Returns `None` if all points form an almost flat line.
pub fn from_convex_polyline(mut points: Vec<Point<Real>>) -> Option<Self> {
if points.is_empty() {
return None;
}
let eps = ComplexField::sqrt(crate::math::DEFAULT_EPSILON);
let mut normals = Vec::with_capacity(points.len());
// First, compute all normals.
Expand Down

0 comments on commit 790016d

Please sign in to comment.