-
-
Notifications
You must be signed in to change notification settings - Fork 55
Fix #168 #185
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
Fix #168 #185
Conversation
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.
This looks good to me. Have you done a benchmark comparison?
Thanks for the review! I probably benchmarked it at the time but I've forgotten now. It's a much simpler algorithm and I would be very surprised if it was slower than the existing code. For me, the more important thing is that this is a well-known and peer-reviewed algorithm and the current implementation is not (perhaps it's a published algorithm, but I'm not familiar with it and it's provenance isn't noted in the code). The Paul Bourke algorithm I've used also seems to give better quality results, as evidenced by the tests I added, etc. |
Oh, there are benchmarks and a bunch of code evaluating the accuracy of various line intersection algorithms in my gist that I linked in my first post. https://gist.github.com/cmcaine/80600c1fd32a6ac3822f2fac4ab93367 |
I mean, posting the I dont have commit access here either. |
I'm not gonna rerun this stuff for a package I don't use any more and a PR that I don't believe is ever going to be merged. 🤷 The short of it is that the algorithm in this PR is better known, better tested, seems to produce better output and (least importantly, imo) is almost certainly faster. Simon can take it or leave it. I appreciate that they're spread thin. |
No worries! I use GeometryOps.jl for this ;) It would just be good to not have correctness issues around and proving inline in comments that a PR is all upside no downside is a pretty reliable way to get it merged by people with zero spare time. |
I've made an updated test script based on @cmcaine's gist. Here are the results with some comments. Precision of results(In cases where both methods find an intersection) The
Finding an intersection when there is one indeedThe
BenchmarksUsing random lines in the whole
Using random coordinates restricted to [-1,1], with 24% of cases having an intersection,
Using only lines that do intersect,
|
Thank you @cmcaine and sorry for taking so long. I'm not familiar with line intersection algorithm and have little time for review. |
Thanks knuesel! Thanks very much Simon for your work on this package (which I maybe use indirectly?) and on many other packages that I and others benefit from 💜. I lost a few hours to this bug and in writing the PR, but you've saved me many more than that over the years :D |
Replaces the intersection algorithm with one that seems more reliable.
See here for the algorithm and explanation: http://paulbourke.net/geometry/pointlineplane/
This algorithm is also used in Turf.js, Turf.jl, etc.
I did a bunch of testing with other algorithms and even tested some algorithms from ChatGPT. You can see some of the testing here: https://gist.github.com/cmcaine/80600c1fd32a6ac3822f2fac4ab93367