|
26 | 26 | # Parametric
|
27 | 27 | ################################################################################
|
28 | 28 |
|
29 |
| -# Map argument domain from [0, 1]³ to Barycentric domain for (::Tetrahedron)(t1, t2, t3) |
| 29 | +# Map argument domain from [0, 1]³ to Barycentric domain for (::Tetrahedron)(t₁, t₂, t₃) |
30 | 30 | function _parametric(tetrahedron::Meshes.Tetrahedron)
|
31 |
| - function f(t1, t2, t3) |
32 |
| - if any(Iterators.map(n -> (n < 0) || (n > 1), (t1, t2, t3))) |
33 |
| - msg = "tetrahedron(t1, t2, t3) is not defined for (t1, t2, t3) outside [0, 1]³." |
34 |
| - throw(DomainError((t1, t2, t3), msg)) |
| 31 | + function f(t₁, t₂, t₃) |
| 32 | + if any(Iterators.map(n -> (n < 0) || (n > 1), (t₁, t₂, t₃))) |
| 33 | + msg = "tetrahedron(t₁, t₂, t₃) is not defined for (t₁, t₂, t₃) outside [0, 1]³." |
| 34 | + throw(DomainError((t₁, t₂, t₃), msg)) |
35 | 35 | end
|
36 | 36 |
|
37 |
| - # Take a triangular cross-section at t3 |
38 |
| - a = tetrahedron(t3, 0, 0) |
39 |
| - b = tetrahedron(0, t3, 0) |
40 |
| - c = tetrahedron(0, 0, t3) |
41 |
| - cross_section = _parametric(Meshes.Triangle(a, b, c)) |
42 |
| - |
43 |
| - return cross_section(t1, t2) |
| 37 | + #= |
| 38 | + Algorithm: |
| 39 | + - Form a barycentric tetrahedron bounded by the points [0, 0, 0], [1, 0, 0], |
| 40 | + [0, 1, 0], and [0, 0, 1]. |
| 41 | + - Use t₃ to take a triangular cross-section of the tetrahedron at points |
| 42 | + [t₃, 0, 0], [0, t₃, 0], and [0, 0, t₃]. |
| 43 | + - Use t₂ to take a line segment cross-section of the triangle between |
| 44 | + points [t₂t₃, 0, t₃ - t₂t₃] and [0, t₂t₃, t₃ - t₂t₃]. |
| 45 | + - Use t₁ to select a point along this line segment, i.e. ā + t₁(b̄ - ā). |
| 46 | + =# |
| 47 | + u₁ = (t₂ * t₃) - (t₁ * t₂ * t₃) |
| 48 | + u₂ = t₁ * t₂ * t₃ |
| 49 | + u₃ = t₃ - (t₂ * t₃) |
| 50 | + return tetrahedron(u₁, u₂, u₃) |
44 | 51 | end
|
45 | 52 | return f
|
46 | 53 | end
|
0 commit comments