Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upTriangulation does not preserve original edges #74
Comments
This comment has been minimized.
This comment has been minimized.
|
@mikelmaron @hjanetzek @zugaldia @incanus @springmeyer |
This comment has been minimized.
This comment has been minimized.
|
This issue troubles me too. |
This comment has been minimized.
This comment has been minimized.
|
@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 . |
This comment has been minimized.
This comment has been minimized.
|
Is this behavior causing any particular issues? It seems like a result I would expect. |
This comment has been minimized.
This comment has been minimized.
|
I think the result of Polygon triangulation should be a mesh, One border could most belong to two triangles. |
This comment has been minimized.
This comment has been minimized.
|
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, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@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. . |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
@mourner , I create a new version at : https://github.com/finscn/earcut/blob/master/src/earcut.js And for |
This comment has been minimized.
This comment has been minimized.
|
Hi @mourner , Is there any news about this issue? thanks. |
This comment has been minimized.
This comment has been minimized.
|
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! |
This comment has been minimized.
This comment has been minimized.
|
I'm still waiting ... :'( I wish it could be fixed some day |
Only `water-huge2` failed . the log says : ``` not ok 18 4464 triangles when expected 4461 ``` I think maybe something is wrong in the test-case.
This comment has been minimized.
This comment has been minimized.
|
Is there any news about this issue ? |
This comment has been minimized.
This comment has been minimized.
|
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.)