-
Notifications
You must be signed in to change notification settings - Fork 208
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
preserve colinear segments #41
Comments
Yeah, filtering fixes some really nasty degenerate cases for the algorithm. You can check this yourself by adding Can you describe in more detail why you can't use triangles on filtered points? Even if unfiltered points set is used for something else, the fact the triangles don't use the colinear vertices won't make a visual difference, right? |
I think about adopting earcut for https://github.com/x3dom/x3dom which currently uses very basic earclipping to triangulate polygons. The main use case I see is extrusions where earclipping is used to fill end caps but the sides are triangulated/connected independently. Also it is just good practice to preserve as much as possible of the input and to have no surprises. |
Closes #41. I’m not sure if it won’t break some edge cases, but unless proven with more tests, we can assume it won’t for now.
Ah, I see — makes sense. I pushed a branch ( This improves performance and fixes this issue but may (or may not) lead to some unhandled edge cases, although we can assume it won't cause any trouble until we find a test case that does. BTW, what do you think about adjacent duplicate (not just colinear) points? Can we remove them safely by default? |
Thanks ! It may be a while since in x3dom earclip function consumers provide their own linked list but I will give adopting earcut.js a try. Also, the x3dom developers have a policy to not include or rely on external libraries but for a small one perhaps after some streamlining (hole support not really required, perhaps not even the cool hashing) it would be a case of absorbing it which is probably acceptable. The copyright notice would be always retained. Having adjacent duplicate points would generally indicate some issue during generation of the polygon but it may happen for some automated procedures. Since zero area triangles are accepted for the sides of an extrusion, again filtering out these out would lead to a mesh with zero area holes and rendering artefacts. But in this case, it may be beneficial as an indicator that the polygon has a problem. So, if possible it would be better to not filter but if necessary it should be done, similar to the colinear cases. BTW, these Hilbert curves may make good test polygons since they have a lot of reflexes and may hit numerical corner cases. They also have colinear segments.
|
@andreasplesch great, thanks! I'll think about merging that branch and making a release then (including your test case too). |
It looks like earcut filters out points along colinear segments of the polygon as these are not required to cover the polygon with triangles. However, I would like to have triangles with a vertex at these filtered out points since the same set of points is used for something else (the sides of a 3d extrusion of the polygon). which does not need the filtering.
Is there a way to avoid the filtering ? It looks the algorithm may rely on not having colinear segments ? Eg. this is done not just for performance reasons ?
The text was updated successfully, but these errors were encountered: