Repository navigation
Avoid 0/0 in get_barycentric_ratio when every weight is zeroed - #17
Merged
Merged
Conversation
Each weight is zeroed when the point is within tol of that edge's line, then the weights are divided by their sum. On a thin triangle a point can be within tol of all three, so the sum is zero and every interpolated value became NaN. Fall back to the nearest corner, still a valid interpolation. Adds a unit test with such a triangle. Fixes komietty#15 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
LGTM. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15.
When the weights' sum is zero or not finite, fall back to the nearest corner (weight 1
there, 0 elsewhere). That is still a valid interpolation (non-negative weights summing
to one), it's exact for values that are constant over the triangle, and for a point
that close to all three edges the triangle is effectively degenerate around it anyway.
Every other path is unchanged.
Adds
a_point_near_all_three_edges_of_a_thin_triangle_gets_finite_weightstosrc/values.rs, which returns NaN weights onmainand passes with this change.Diff (src/values.rs):
🤖 Generated with Claude Code