diff --git a/crates/fj-math/src/triangle.rs b/crates/fj-math/src/triangle.rs index 92cbbb0fa..2780a410d 100644 --- a/crates/fj-math/src/triangle.rs +++ b/crates/fj-math/src/triangle.rs @@ -43,6 +43,16 @@ impl Triangle { area > Scalar::default_epsilon() } + /// Convert barycentric coordinates to a point + pub fn point_from_barycentric_coords( + &self, + [wa, wb, wc]: [Scalar; 3], + ) -> Point { + let [a, b, c] = self.points; + let coords = a.coords * wa + b.coords * wb + c.coords * wc; + Point { coords } + } + /// Normalize the triangle /// /// Returns a new `Triangle` instance with the same points, but the points