Earcut triangulation not working for this case

Hello everybody,

I have problems with my triangulation algorithm. It works fine but it doesn’t work in some weird cases.
I have an external algorithm that computes rotations, etc. The data is issued from that algorithm and should work in the triangulation algorithm but don’t.

Please find here the code I am talking about: https://codepen.io/ads4/pen/JjVVOep
The result of the triangulation is in the console.

The first sheet is well triangulated, but the 2nd and the 3rd are not. It’s fine for the 4th one.

I really need help, thank you really much in advance.

start by plotting your polygons to see what’s wrong with them

1 Like

the polygons are perfectly fine, the problem comes from the triangulation
I think it is related to the inversion of Y and Z axes

how does z axis fit into this? earclip algo operates in 2D

Hey, your codepen is 404ing for me.

1 Like