Fix bugs in closest_point_on_lines#63
Merged
WhyPenguins merged 3 commits intothoth-tech:t2-2024from Sep 26, 2024
Merged
Conversation
Liquidscroll
approved these changes
Aug 27, 2024
Liquidscroll
left a comment
There was a problem hiding this comment.
Looks good to me!
I pulled these changes and ran the tests locally. Great work on the interactive testing! Love it! As far as I can tell it is working correctly.
hugglesfox
approved these changes
Aug 30, 2024
hugglesfox
left a comment
There was a problem hiding this comment.
Looks good. Great job on the testing
12 tasks
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.
Description
I attempted to use the closest_point_on_lines function in my circle_triangle_intersects function and found that it behaved strangely. Further investigation revealed two major bugs. First, despite
resultbeing initialised, it is never returned. Second,min_distis initialised as-1, which means that the comparisonmin_dist > dstwill always resolve tofalseasdstmust be a positive number returned frompoint_point_distance. The special case whenlines.size() == 0is handled correctly by returning0,0withline_idx=0, however I felt that an early return for this case would make the function easier to understand.It is possible that the incorrect behavior of this function has lead to workarounds being used in projects. Therefore, I believe that this is a breaking change. Despite this, I believe that the functionality must be rectified for the sake of correctness.
Type of change
expected)
How Has This Been Tested?
I added tests to sktest which show the function working in real-time. They indicate the position of the closest point, as well as which individual line contains the closest point. I also added a few numerical tests which print their results to the console.
Testing Checklist
Checklist