-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Wrong result for two simple polygons #110
Comments
Thanks for the detailed example and the C++ reference, I will try and figure it out |
@abelramos Until this gets fixed, I have found that adding very small (like 0.0005), pseudorandom values to the coordinates will prevent this. The problem occurs when a point falls exactly on another line. Our app has grid snapping, I can confirm that this happens all the time. |
I have tested this case with polybooljs (another implementation of the Martinez algorithm) and there it seems to work: So maybe it helps to have a look where the implementations differ. |
It's not exactly the same algorithm, but thanks for the reference! |
Ah interesting, I was wondering about that already. What is this implementation here actually based on? I've found three "original" versions of the Martinez algorithm:
|
it's the last one |
Exactly. I can also confirm it is not related to floating-point arithmetic and/or epsilon values, I tested the implementation with a type for rational numbers, and the issue remains. |
Yes, I tried with that one too. It works. However, I believe this implementation is faster than the other one, that's why I'm interested in a fix for this one. |
afair the other one uses only linked lists (instead of a tree), plus solid improvements don't seem to get merged for... reasons |
I would love to get some help here, I didn't have time to look at it recently |
Exactly, I came to the same conclusion here after reading the code a bit.
I'd like to have a look, but I don't have access to the paper :(. |
@bluenote10 if you send me an email me at rowanwinsemius dot id dot au , then I can supply the paper |
I'm working on my own implementation of the Martinez paper, and I started there from the original implementation in C++ that they published (I need integer coordinates). Since I was having the same issue: here's what I tracked what was going wrong: When the status line reaches point (120, 210), the line segments starting at (120,210) are incorrectly inserted between segment (111,228)-(129,192) and (80,300)-(115,96). This causes the segments to have the wrong neighbors. So what likely needs work, is the segment comparer. I noticed that you're using a comparer somewhat similar to the C++ version so I'm guessing that's also going to apply here. When I made sure the segment comparer ordered them correctly for this one use case, the correct result was being computed. |
Thank you so much ! I will try that
…On Fri, 19 May 2023 at 22:25, Sven ***@***.***> wrote:
I'm working on my own implementation of the Martinez paper, and I started
there from the original implementation in C++ that they published (I need
integer coordinates). Since I was having the same issue: here's what I
tracked what was going wrong:
When the status line reaches point (120, 210), the line segments starting
at (120,210) are incorrectly inserted between segment (111,228)-(129,192)
and (80,300)-(115,96). This causes the segments to have the wrong neighbors.
So what likely needs work, is the segment comparer. I noticed that you're
using a comparer somewhat similar to the C++ version so I'm guessing that's
also going to apply here. When I made sure the segment comparer ordered
them correctly for this one use case, the correct result was being computed.
—
Reply to this email directly, view it on GitHub
<#110 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAGSBFCZSHJ4FRJTFJKU2DXG7JKXANCNFSM4KAIIFEQ>
.
You are receiving this because you were assigned.Message ID:
***@***.***>
|
These are my two simple polygons:
with coordinates:
And this is the resulting union:
There are no vertical edges, in fact, no two points share the same x-coordinate. I believe the issue here is with the
otherInOut
property not being correctly computed as these are the sweep events withotherInOut
set to true after the subdivision step:I also tried with the C++ code available online from the original paper, and the resulting union is the same.
The text was updated successfully, but these errors were encountered: