Skip to content

Commit

Permalink
Expose both areas of triangles to the API
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoledoux committed Jul 16, 2024
1 parent 76f24ca commit f7c2a8e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,28 @@ impl Triangulation {
}
}

pub fn area2d_triangle(&self, tr: &Triangle) -> Result<f64, StartinError> {
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<f64, StartinError> {
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<usize, StartinError> {
match self.is_vertex_removed(vi) {
Expand Down

0 comments on commit f7c2a8e

Please sign in to comment.