-
Notifications
You must be signed in to change notification settings - Fork 28
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
Canonical segment orientation for robust intersections #23
Comments
Just pushed an updated version that maintains the old Overlap orientation conventions, if that matters. https://github.com/nick-parker/rust-geo-booleanop/tree/robust-intersection I believe the only failing tests now are due to the floating point differences this change is meant to fix. |
Yeah interesting idea. I would definitely have to think / experiment a lot more to come to a final conclusion but my immediate thoughts are:
|
Maybe it would make sense to have a minimally checked 'naked' intersection function, and then a fully checked second function that calls the naked version after canonicalization? That would let us optimize the call sites where we know certain conditions are guaranteed, but also encourage us to think about those guarantees and give us an escape hatch if there are any sites where we can't provide them. |
There are only two callsites:
I'm wondering if we can actually come up a test case that fails because of this inconsistency. A first question to investigate would be: Is it possible to get different result types |
Hi there, sorry I've been distracted by other projects. Still can't quite jump into this one like I want, but I poked around my test here a bit more, and you can definitely get different result types. The easiest case is if the two segments share an endpoint. That's order-dependent every time. However if the midpoint of one segment is an endpoint of another, it only sometimes differs depending on the specific random coordinates. I haven't poked around yet, but I bet you can also get it to flip between a point intersection and an overlap intersection. |
I rebased this onto #24 because the outdated geo_types had been bugging me, and I plotted all the generic_test_cases which you can see in the attached pdf. I'm not sure which if any tests are supposed to fail, but issue103 was marked that flipping ba causes it to fail, and in the attached pdf you can see that they match perfectly now. Rebased branch: https://github.com/nick-parker/rust-geo-booleanop/tree/robust-intersection Edit: Ahhh dang, I just realized the python plot script just plots, it doesn't execute the actual operations. Are these geojson files updated when I run the tests or what? Edit2: Nevermind, noticed the /tests/README. I haven't fixed issue103 SwapResult. Also I ran the benchmarks and this is around 20% slower :( |
Currently, this test fails:
The accumulation of floating point errors in intersection depends on the order of its arguments, when all 8 permutations ought to be the exact same intersection.
If we change the intersection function to enforce a canonical orientation for the two line segments before performing its calculations, this test will pass and naive equality checks on intersection results will be reliable.
We perform most of the comparisons necessary to enforce such a convention already in constructing the intersection bounding box. See this commit in my fork:
nick-parker@ae3159f
Would this sort of robustness be helpful? I haven't dug into the main library enough to know yet, and my branch breaks a bunch of tests right now because it changes the orientation of eg some Overlap results.
The text was updated successfully, but these errors were encountered: