From 697fe9d03335bdb9d5c3ccbeb6a344fd45e58aba Mon Sep 17 00:00:00 2001 From: Emily Selwood Date: Tue, 24 Jan 2023 08:51:14 +0000 Subject: [PATCH] prepare for publish --- Cargo.toml | 3 +++ src/polygon.rs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index d6def15..9cf89a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 = [ diff --git a/src/polygon.rs b/src/polygon.rs index e6450ad..93d9f42 100644 --- a/src/polygon.rs +++ b/src/polygon.rs @@ -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) {