-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Implement closest_point for Segment[23]d. #20130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
let closest = segment.closest_point(*point); | ||
assert!( | ||
point.distance_squared(closest) <= point.distance_squared(segment.point1()), | ||
"Closest point must always at least as close as either vertex." |
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.
I think this sentence is missing a "be"
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.
Oh no, grammr.
@@ -2349,15 +2349,15 @@ mod tests { | |||
let closest = segment.closest_point(*point); | |||
assert!( | |||
point.distance_squared(closest) <= point.distance_squared(segment.point1()), | |||
"Closest point must always at least as close as either vertex." | |||
"Closest point must always at be least as close as either vertex." |
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.
hum, it's "must always be at least" x) sorry for pestering :p
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.
Brain not working today, oops.
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.
Looks good! Pretty much exactly the same implementation as what I have in Peck.
This uses a more intuitive and simple approach in terms of the naming and comments, whereas I (and Parry, Box2D, etc.) explicitly describe the barycentric coordinates and Voronoi regions (see the version I linked on Discord). Both are fine for this line segment case, but for the more complicated simplices like triangles and tetrahedra, IMO you really need to use Voronoi regions to make sense of things.
I'm kind of biased towards using barycentric coordinates and Voronoi regions for all simplices to have them be more consistent and kind of build on each other, but I'm fine with this for now :)
Also I expect these to be moved under a trait like |
Objective
Solution
Testing