From f7c2a8efe88df6450f7f29f2cd34ffdb8a495c60 Mon Sep 17 00:00:00 2001 From: Hugo Ledoux Date: Tue, 16 Jul 2024 10:40:15 +0200 Subject: [PATCH] Expose both areas of triangles to the API --- src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ba62c27..73001ca 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -957,6 +957,28 @@ impl Triangulation { } } + pub fn area2d_triangle(&self, tr: &Triangle) -> Result { + match self.is_triangle(tr) { + false => Err(StartinError::TriangleNotPresent), + true => Ok(geom::area2d_triangle( + &self.stars[tr.v[0]].pt, + &self.stars[tr.v[1]].pt, + &self.stars[tr.v[2]].pt, + )), + } + } + + pub fn area3d_triangle(&self, tr: &Triangle) -> Result { + match self.is_triangle(tr) { + false => Err(StartinError::TriangleNotPresent), + true => Ok(geom::area3d_triangle( + &self.stars[tr.v[0]].pt, + &self.stars[tr.v[1]].pt, + &self.stars[tr.v[2]].pt, + )), + } + } + /// Returns the degree of the vertex with ID `vi`. pub fn degree(&self, vi: usize) -> Result { match self.is_vertex_removed(vi) {