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

Zero length line segments ruin Polygon2D objects #37

Open
zostay opened this issue Jul 16, 2021 · 1 comment
Open

Zero length line segments ruin Polygon2D objects #37

zostay opened this issue Jul 16, 2021 · 1 comment

Comments

@zostay
Copy link
Contributor

zostay commented Jul 16, 2021

I'm not really sure this is a bug, but I recently discovered that if you build a polygon from a set of points, you need to be careful to make sure that no consecutive points are equal. This results in a 0 length line segment and causes the SDF code to fail. It will either end up finding no object at all or it will find a series of points that evaluate to NaN coordinates.

I was working on extruding objects from some dirty polygon data that included such. Also my manipulation code expects a closed polygon to be represented with the first and last point being equal. So, I had to make sure to write my code such that the last point is skipped and with code to guard against 0 length segments.

It might be nice to add those the Polygon2D constructor, or maybe just add a note in the docs about the problem.

@deadsy
Copy link
Owner

deadsy commented Jul 16, 2021

I'm not suprised - I didn't anticipate useless vertices. The helper routines in poly.go do vertex manipulation. There's a "fixups" routine that could possibly be used to strip out successive duplicate vertices.

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

2 participants