-
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
Triangulation does not preserve original edges #74
Comments
@mikelmaron @hjanetzek @zugaldia @incanus @springmeyer |
This issue troubles me too. |
@mikelmaron @hjanetzek @zugaldia @incanus @springmeyer @zzfoo I changed
change It could solve this problem , but I don't know whether it is the best way. My test case :
Just replace the . |
Is this behavior causing any particular issues? It seems like a result I would expect. |
I think the result of Polygon triangulation should be a mesh, One border could most belong to two triangles. |
If one border shared to many triangles , the triangulation will lost the value in the real-world(e.g. : NavMesh Pathfinding , Mesh Transform ) Maybe earcut would not be used in those use case , but it's the base of Polygon triangulation, |
@mourner , there is a document about Triangulation : In the famous & classic book "Geometric Tools for Computer Graphics" , there is similar claim : The key point : "The edges are only allowed to intersect at the vertices. ". In fact, by definition, the result of current version earcut in my test case is not Triangulation at all. . And the most words above are translated by google. . |
I see the issue now — thanks for the explanation. I don't have immediate suggestions to fix this — this problem might stem from the original tactics from https://www.cosy.sbg.ac.at/~held/projects/triang/triang.html to deal with degenerate cases by filtering out collinear points at various stages of the algorithm. Needs investigation. |
Thank you , @mourner . And there is a better test case : // replace the testPoints in viz.js.
var testPoints = [
[
[10, 10],
[300, 10],
[300, 300],
[10, 300]
],
[
[50, 50],
[100, 50],
[100, 100],
[50, 100]
],
[
[150, 50],
[200, 50],
[200, 100],
[150, 100]
],
[
[50, 150],
[100, 150],
[100, 200],
[50, 200]
],
[
[150, 150],
[200, 150],
[200, 200],
[150, 200]
],
]; My solution can't solve this bug in this test case, So I think this test case is more representative. |
@mourner , I think the bug at The node linkList that return value of I think the correct one should be like this : And , whatever , 10 ,11 ,12 will be in one line , the filterPoints will remove 11. |
@mourner I'm using earcut.js to divide the walkable area of our game map into triangles. I was expecting all the triangles are fully connected with their neighbors such that game characters can walk from one triangle area to another unobstructedly as long as they are walking through the common edge. |
To fix mapbox#74 Because the algorithm has been changed , the `expectedTriangles` & `expectedDeviation` in the test cases will have to changed. So the current test case will not valid for this PR.
@mourner , I create a new version at : https://github.com/finscn/earcut/blob/master/src/earcut.js And for |
Hi @mourner , Is there any news about this issue? thanks. |
No updates on this yet unfortunately. If anyone has an idea on how to fix the issue without breaking existing test cases, I'll be glad to see a PR! |
I'm still waiting ... :'( I wish it could be fixed some day |
Is there any news about this issue ? |
I think this is a serious problem , Is there any plan for fixing it ? |
In the above image, the two neighbor triangles (where the red arrow points) are not fully connected, while all other neighbor triangles are.
(please let me know if I didn't make myself clear.)
The text was updated successfully, but these errors were encountered: