Skip to content

Commit

Permalink
Update style for similar Triangle function
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeingold committed Dec 27, 2024
1 parent 6fd00b7 commit 3759ef6
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/specializations/Triangle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,23 @@ end

# Map argument domain from [0, 1]² to Barycentric domain for (::Triangle)(t1, t2)
function _parametric(triangle::Meshes.Triangle)
function f(t1, t2)
if any(Iterators.map(n -> (n < 0) || (n > 1), (t1, t2)))
msg = "triangle(t1, t2) is not defined for (t1, t2) outside [0, 1]²."
throw(DomainError((t1, t2), msg))
function f(t₁, t₂)
if any(Iterators.map(n -> (n < 0) || (n > 1), (t₁, t₂)))
msg = "triangle(t₁, t₂) is not defined for (t₁, t₂) outside [0, 1]²."
throw(DomainError((t₁, t₂), msg))
end

t1t2 = t1 * t2
return triangle(t1t2, t2 - t1t2)
# Use t₂ to take a line segment cross-section between points
"""
# Algorithm:
- Form a barycentric triangle bounded by the points [0, 0], [1, 0], and [0, 1].
- Use t₂ to take a line segment cross-section of the triangle between points
[0, t₂] and [t₂, 0].
- Use t₁ to select a point along this line segment, i.e. ā + t₁(b̄ - ā).
"""
u₁ = t₁ * t₂
u₂ = t₂ - (t₁ * t₂)
return triangle(u₁, u₂)
end
return f
end

0 comments on commit 3759ef6

Please sign in to comment.