mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-07 11:28:28 +00:00
Add Triangle::center
This commit is contained in:
parent
0a4fe71bf1
commit
4c53779f78
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user