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

Padding fails at arbitrary point for some polygons #30

Open
huberf opened this issue Nov 1, 2021 · 3 comments
Open

Padding fails at arbitrary point for some polygons #30

huberf opened this issue Nov 1, 2021 · 3 comments

Comments

@huberf
Copy link

huberf commented Nov 1, 2021

I have a relatively simple polygon shown in this plot:
image

It has slightly angled corners, but no self-intersection, concavity or other odd behavior. When I add padding of 4.8 it succeeds (and is now a simple polygon with 4 sides) but when this increase to 4.9 or higher it fails. However, if I add 4 padding and then add 1 padding to the created polygon, it works and appears to correctly create a polygon with an effective padding of 5.

Here is the code to reproduce:

let Offset = require('polygon-offset')
let offset = new Offset()
let a = [[0.5298861641722039,723.3616754870759],[87.9120549728682,723.0000176351272],[87.91417247478793,722.0000198770368],[89.4375266032173,2.590654049084369],[88.02779525598075,2.0021133264491264],[2.6958948009635018,2.0310984560503553],[2.0250343895624585,3.3632278972327185],[2.022957794804972,4.363225741107499],[0.5298861641722039,723.3616754870759]]
offset.data(a).padding(4.8) // works
offset.data(a).padding(4.9) // fails

The logging specifies that it has switched to brute force at 4.9, and then either fails with:
image

Or it returns 2 polygons (which does not make sense as this is perfectly convex polygon).

I have experienced the issue of the algorithm incorrectly returning 2 polygons instead of one with other point sets, but this was the simplest polygon yet that still ran into issues with the polygon.

Thank you!

@whucj
Copy link

whucj commented Nov 8, 2022

I have the same problem.

@w8r
Copy link
Owner

w8r commented Nov 8, 2022

Thanks a lot! The issue here is with the underlying polygon clipping algorithm. I will check it there.

@whucj
Copy link

whucj commented Nov 8, 2022

Thanks a lot! The issue here is with the underlying polygon clipping algorithm. I will check it there.

Thanks.
By debugging the code, it is found that the problem is the union method !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants