-
Notifications
You must be signed in to change notification settings - Fork 55
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
Intersection/union of two valid polygons can create invalid result. #54
Comments
Wow, Oliver, But the fact that function The method So if we want to use the result in boolean operations, we have to clean up self-intersected polygons. flatten-js library does not have a method to fix self-intersected polygons, but it may be added if someone will ask. But again, I will check all your examples if they give legal results, and add them to the test set. Maybe I will change the name of the method to Thank you for contribution to this project Best regards, |
Hi Alex :) Is my assumption that a boolean operation between simple polygons should result in a simple polygon incorrect? In my case I do care about the resulting polygons being valid because:
I would be very interested in a feature to fix non-simple polygons! I looked around but struggled to find an algorithm for doing this... |
Hi Oliver, Strictly speaking, you are right, boolean operation with valid polygon should give valid result. As for current implementation of self-intersection check in flatten-js library I admit that it is too loose. (We can't know it from the picture, but from the way it was constructed) So from this discussion I see 3 action items:
It will take some time, but I can do this. Best regards, |
I understand re numerical errors etc. After having tried a few polygon manipulation libraries I'm getting the strong impression that they are very hard to engineer well. Flatten-js is by far the best and most stable so kudos to you! It sounds like for most practical intents and purposes these "invalid" polygons will not be an issue. I can certainly update my code to ignore degenerate polygons, thanks for the tip :) |
Got some more for you :)
https://codesandbox.io/s/wild-snow-0801g?file=/src/index.ts
EDIT: updated the link for one that includes multiple failing pairs of polygons.
The text was updated successfully, but these errors were encountered: