Skip to content

Commit

Permalink
geometry - make triangle functions public
Browse files Browse the repository at this point in the history
  • Loading branch information
arrufat committed Jan 24, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 7251c91 commit 2f26818
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/geometry.zig
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ test "Rectangle grow and shrink" {
}

/// Returns true if, and only if, p is inside the triangle `tri`.
fn pointInTriangle(comptime T: type, p: Point2d(T), tri: [3]Point2d(T)) bool {
pub fn pointInTriangle(comptime T: type, p: Point2d(T), tri: [3]Point2d(T)) bool {
const s = (tri[0].x - tri[2].x) * (p.y - tri[2].y) - (tri[0].y - tri[2].y) * (p.x - tri[2].x);
const t = (tri[1].x - tri[0].x) * (p.y - tri[0].y) - (tri[1].y - tri[0].y) * (p.x - tri[0].x);

@@ -181,7 +181,7 @@ test "pointInTriangle" {
}

/// Returns the baricenter of the triangle.
fn findBaricenter(comptime T: type, triangle: [3]Point2d(T)) Point2d(T) {
pub fn findBaricenter(comptime T: type, triangle: [3]Point2d(T)) Point2d(T) {
return .{
.x = (triangle[0].x + triangle[1].x + triangle[2].x) / 3,
.y = (triangle[0].y + triangle[1].y + triangle[2].y) / 3,

0 comments on commit 2f26818

Please sign in to comment.