Skip to content

Commit

Permalink
Merge pull request #2452 from hannobraun/triangle
Browse files Browse the repository at this point in the history
Add `Triangle::point_from_barycentric_coords`
  • Loading branch information
hannobraun committed Aug 13, 2024
2 parents b787d99 + c0d4db9 commit 6e747ac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/fj-math/src/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ impl<const D: usize> Triangle<D> {
area > Scalar::default_epsilon()
}

/// Convert barycentric coordinates to a point
pub fn point_from_barycentric_coords(
&self,
[wa, wb, wc]: [Scalar; 3],
) -> Point<D> {
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
Expand Down

0 comments on commit 6e747ac

Please sign in to comment.