Skip to content

Commit

Permalink
prepare for publish
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyselwood committed Jan 24, 2023
1 parent ae20d19 commit 697fe9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[package]
name = "polygonical"
description = "2d polygon geometry and operations"
keywords = ["2d", "geometry", "polygon"]
license = "MIT"
version = "0.1.0"
edition = "2021"
authors = [
Expand Down
5 changes: 5 additions & 0 deletions src/polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ impl Polygon {
}

/// Return the area of this polygon
/// Note: This will panic if the polygon is self intersecting.
pub fn area(&self) -> f64 {
if self.is_self_intersecting() {
panic!("Can not calculate the area of a self intersecting polygon")
}

let mut triangle_sum = 0.0;
let sides = self.sides();
for s in sides.iter().take(sides.len() - 1) {
Expand Down

0 comments on commit 697fe9d

Please sign in to comment.