Skip to content

Commit

Permalink
Ensure convex polygon has more than 2 vertices
Browse files Browse the repository at this point in the history
  • Loading branch information
hakolao committed Oct 13, 2023
1 parent af38912 commit 76c7b57
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/shape/convex_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ impl ConvexPolygon {
pub fn from_convex_polyline(mut points: Vec<Point<Real>>) -> Option<Self> {
let eps = ComplexField::sqrt(crate::math::DEFAULT_EPSILON);
let mut normals = Vec::with_capacity(points.len());

// First, compute all normals.
for i1 in 0..points.len() {
let i2 = (i1 + 1) % points.len();
Expand Down Expand Up @@ -64,7 +63,7 @@ impl ConvexPolygon {
points.truncate(new_length);
normals.truncate(new_length);

if points.len() != 0 {
if points.len() > 2 {
Some(ConvexPolygon { points, normals })
} else {
None
Expand Down

0 comments on commit 76c7b57

Please sign in to comment.