-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add Point3d.nearestPointOnLine and Point3d.nearestPointOnTriangle #114
Comments
Just looking through the code now - a few questions/comments:
In general I try to avoid too many circular dependencies where lower-level concepts like points are aware of higher-level concepts like triangles; I think currently there are a bunch of unavoidable cyclic dependencies between what I think of as the true 'primitives' (points, vectors, directions, axes, planes, frames, sketch planes, bounding boxes) but then there's a pretty clear separation between those and higher-level actual 'geometry' types (line segments, triangles, arcs, splines etc.). |
It currently returns the point itself if it's inside the triangle (or rather, the point projected onto the triangle).
Those are good names too. I don't think it's a good idea to differentiate with
Oops. I never even thought to look for "contains" though it seems obvious in hindsight. I suppose you can swap out implementations if you'd like, or copy over the tests I wrote to make extra certain the function does what it's supposed to.
That's fair and with that in mind, |
I've implemented
Point3d.nearestPointOnLine
andPoint3d.nearestPointOnTriangle
and would like to add them to elm-geometry. Code for them can be found here and tests can be found here.Note that the tests sometimes fail when a fuzzer manages to get nearestPointOnTriangle to return the wrong result due to numerical instability. I'm not sure yet if this is a problem in practice or if it only happens with very unusual triangles (i.e, two vertices are 0.0001 meters apart and the third vertex is 100000 meters away).
In response to this comment on Slack
I chose to place these functions in Point3d because I could come up with more intuitive names then. Additionally, to me it feels like Point3d is the "subject" of these functions and it feels more natural then that the functions are in the Point3d module.
The text was updated successfully, but these errors were encountered: