earcut icon indicating copy to clipboard operation
earcut copied to clipboard

Triangulation - wrong output?

Open RARgames opened this issue 5 years ago • 0 comments

After executing earcut([1, 1, 5, 1, 5, 5, 1, 5, 2,2, 3,2, 3,3, 2,3, 4,4, 5,4, 5,5, 4,5, 4,3, 5,3, 5,4, 4,4, 4,2, 5,2, 5,3, 4,3, 2,1, 3,1, 3,2, 2,2], [4, 8, 12, 16, 20]);

the result is:

Output
0: 0
​
1: 20
​
2: 23
​
3: 22
​
4: 21
​
5: 1
​
6: 17
​
7: 22
​
8: 1
​
9: 3
​
10: 0
​
11: 4
​
12: 6
​
13: 5
​
14: 16
​
15: 3
​
16: 4
​
17: 7
​
18: 6
​
19: 16
​
20: 19
​
21: 7
​
22: 12
​
23: 15
​
24: 9
​
25: 8
​
26: 7
​
27: 7
​
28: 8
​
29: 11
​
30: 3
​
31: 7
​
32: 15
​
33: 15
​
34: 14
​
35: 2
​
36: 2
​
37: 3
​
38: 15
​
length: 39

image From above table we can see that triangles marked red: 9,12,13 are wrong - because they overlap the 2nd hole. Also triangle 11 is overlapping triangle 10.

Is my input data correct? I'd like to achieve something like this: image

RARgames avatar Apr 24 '20 19:04 RARgames