From 3759ef622b4258b50e2a0122b02e42791503eb2e Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Thu, 26 Dec 2024 23:33:39 -0500 Subject: [PATCH] Update style for similar Triangle function --- src/specializations/Triangle.jl | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/specializations/Triangle.jl b/src/specializations/Triangle.jl index 26f3ea15..4416f30b 100644 --- a/src/specializations/Triangle.jl +++ b/src/specializations/Triangle.jl @@ -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