Skip to content
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

union: tried to create degenerate segment. #85

Closed
pentacular opened this issue Aug 14, 2019 · 4 comments
Closed

union: tried to create degenerate segment. #85

pentacular opened this issue Aug 14, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@pentacular
Copy link

const a = [[[0.17283,18.40241],[0.22772,18.48456],[0.22772,18.48461],[0.17281,18.40243],[0.17283,18.40241]]];
const b = [[[0.11978,18.32302],[0.14685,17.90202],[0.15809,18.11877],[0.11978,18.32302],[0.11978,18.32306],[0.11978,18.32302]]];
polygonClipping.union(a, b);

produces

"Tried to create degenerate segment at [0.11978, 18.32302]"

Which is a bit odd, because the two shapes don't overlap.

@mfogel
Copy link
Owner

mfogel commented Aug 16, 2019

Ah, nice. Thank you for the bug report @pentacular I've reproduced the failure on my side with the latest on master.

One of those two polygons is really thin, I would assume that's what's prompting the library to barf. It's trying to create a segment from [0.11978, 18.32302] to [0.11978, 18.32302], and there's a check in there to avoid creating of zero-length segments.... that's what's throwing the error.

Do you have a preference as to which of the bugs you've reported I look at first? Cheers.

@mfogel mfogel added the bug Something isn't working label Aug 16, 2019
@pentacular
Copy link
Author

Thanks for looking into it. :)

Either order is fine by me.

@pentacular
Copy link
Author

I wonder if an option to drop zero length segments would be reasonable?

@mfogel mfogel closed this as completed in 3a67c13 Aug 16, 2019
@mfogel
Copy link
Owner

mfogel commented Aug 16, 2019

Good thought - the library already does try to drop zero length segments by default. What was going on here was one of the input polygons has an infinitely thin 'peninsula' sticking off one of its vertices. The algorithm was getting confused trying to trim this off.

Screen Shot 2019-08-16 at 4 06 07 PM

Thanks for the bug report, appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants