Add Triangle::center

This commit is contained in:
Hanno Braun 2025-03-21 21:39:01 +01:00
parent 0a4fe71bf1
commit 4c53779f78

View File

@ -43,6 +43,13 @@ impl<const D: usize> Triangle<D> {
area > Scalar::default_epsilon()
}
/// # Compute the center point of the triangle
pub fn center(&self) -> Point<D> {
let [a, b, c] = self.points;
let coords = (a.coords + b.coords + c.coords) / 3.;
Point { coords }
}
/// # Convert a set of barycentric coordinates on the triangle into a point
pub fn point_from_barycentric_coords(
&self,