-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from DanielVandH/triangle
Triangle caching
- Loading branch information
Showing
15 changed files
with
150 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,18 @@ | ||
function _compute_triangle_coordinates( | ||
tri::Triangulation{P,T,BN,W,I,E,Es,BC,BEM,GVM,GVR,BPL,C,BE}, | ||
interpolation_point, | ||
cache::NaturalNeighboursCache{F}=NaturalNeighboursCache(tri); | ||
project=true, | ||
kwargs... | ||
) where {P,T,BN,W,I,E,Es,BC,BEM,GVM,GVR,BPL,C,BE,F} | ||
coordinates = get_coordinates(cache) | ||
envelope = get_envelope(cache) | ||
last_triangle = get_last_triangle(cache) | ||
V = jump_and_march(tri, interpolation_point; try_points=last_triangle[], kwargs...) | ||
i, j, return_flag = check_for_extrapolation(tri, V, interpolation_point, last_triangle) | ||
return_flag && return two_point_interpolate!(coordinates, envelope, tri, i, j, interpolation_point, project) | ||
i, j, k = triangle_vertices(V) | ||
resize!(coordinates, 3) | ||
resize!(envelope, 3) | ||
λ₁, λ₂, λ₃ = _compute_triangle_barycentric_coordinates(tri, interpolation_point, i, j, k) | ||
coordinates[1] = λ₁ | ||
coordinates[2] = λ₂ | ||
coordinates[3] = λ₃ | ||
envelope[1] = i | ||
envelope[2] = j | ||
envelope[3] = k | ||
return NaturalCoordinates(coordinates, envelope, interpolation_point, tri) | ||
end | ||
|
||
function _compute_triangle_barycentric_coordinates(tri, interpolation_point, i, j, k) | ||
function _compute_triangle_shape_coefficients(tri, i, j, k) | ||
p, q, r = get_point(tri, i, j, k) | ||
x₁, y₁ = getxy(p) | ||
x₂, y₂ = getxy(q) | ||
x₃, y₃ = getxy(r) | ||
x, y = getxy(interpolation_point) | ||
Δ = (y₂ - y₃) * (x₁ - x₃) + (x₃ - x₂) * (y₁ - y₃) | ||
λ₁ = ((y₂ - y₃) * (x - x₃) + (x₃ - x₂) * (y - y₃)) / Δ | ||
λ₂ = ((y₃ - y₁) * (x - x₃) + (x₁ - x₃) * (y - y₃)) / Δ | ||
λ₃ = one(λ₁) - λ₁ - λ₂ | ||
return λ₁, λ₂, λ₃ | ||
end | ||
|
||
function compute_natural_coordinates(::Triangle, tri, interpolation_point, cache=NaturalNeighboursCache(tri); kwargs...) | ||
return _compute_triangle_coordinates(tri, interpolation_point, cache; kwargs...) | ||
px, py = getxy(p) | ||
qx, qy = getxy(q) | ||
rx, ry = getxy(r) | ||
Δ = qx * ry - qy * rx - px * ry + rx * py + px * qy - qx * py | ||
s₁ = (qy - ry) / Δ | ||
s₂ = (ry - py) / Δ | ||
s₃ = (py - qy) / Δ | ||
s₄ = (rx - qx) / Δ | ||
s₅ = (px - rx) / Δ | ||
s₆ = (qx - px) / Δ | ||
s₇ = (qx * ry - rx * qy) / Δ | ||
s₈ = (rx * py - px * ry) / Δ | ||
s₉ = (px * qy - qx * py) / Δ | ||
shape_function_coefficients = (s₁, s₂, s₃, s₄, s₅, s₆, s₇, s₈, s₉) | ||
return shape_function_coefficients | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1fb57cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
1fb57cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/110535
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: