Repository: godot
Issue: Geometry2D.triangulate_polygon() sometimes returns nothing if the input polygon has "degenerate" parts / Geometry2D.clip_polygons returns degenerate parts
Labels: bug,topic:2d

### Tested versions

Godot 4.2.2

### System information

Windows 10 64 bits NVIDIA GeForce GTX 1060

### Issue description

I'm trying to clip triangles between them using `Geometry2D.clip_polygons`. Since I need triangles, I also triangulate the result.

This inevitably led me to find annoying edge cases such as this one:

![image](https://github.com/godotengine/godot/assets/1311555/f7ccb0ab-af25-43fd-be4a-3def21be1164)

Red: triangle A (drawn over for the sake of explanation)
Green: triangle B
Blue: the result of `Geometry2D.clip_polygons(A, B)`, which ends up with a "degenerate segment".

Points of the blue polygon are:
```
[(350, 280), (314, 331), (314, 280), (350, 280), (314, 260.8), (314, 260.8)]
```
Which is unexpectedly open, and even contains a duplicate point.

Giving the blue result to `Geometry2D.triangulate_polygon` sometimes returns an empty array, which is not what I expect. I expect the non-degenerate part to be returned. 
Alternatively, I would also be fine if the degenerate part was returned as a degenerate triangle, because it can be removed relatively easily afterwards.
Another alternative would be for `clip_polygons` to not return degenerate parts in the first place.
Not sure what we should consider as the right behavior.

But right now I don't know how I can work around this, and cases like this inevitably occur in my use case.


### Steps to reproduce

Send two overlapping triangles with one of their edges aligned as shown to `clip_polygons`, then send the output of that to `triangulate_polygon`. Sometimes the outcome differs, likely due to float precision.

### Minimal reproduction project (MRP)

[ClipPolygonCase1.zip](https://github.com/godotengine/godot/files/15143312/ClipPolygonCase1.zip)

In this project, the number of indices returned by `triangulate_polygon` is printed, and it's always 0.

----

My original use case leading me to this, is that I want to clip arbitrary 2D triangle-meshes. Like, I have 2D mesh A, 2D mesh B, and I want to "subtract" B from A.
The problem is, since they are arbitrary, they are not "polygons". I didn't find a function to create polygons from 2D meshes. And even if I could get polygons from them, they could be open paths with undefined amount of holes in them, and I find functions in `Geometry2D` are not easy to use in situation like this. So I ended up deciding to work solely with triangles, which produces results with too many triangles, yet correct (if we exclude the present issue, which you can see here as holes in the result):
![image](https://github.com/godotengine/godot/assets/1311555/7d9b8e7b-9220-444f-9606-ea21a98011a0)

The plan after that being to simplify these triangles somehow, however I also couldn't find something I can use for this. Once again if I could turn triangles into polygons and then triangulate, that could do the trick, but that's not a thing.
When I search this topic I keep finding either stuff for 3D (but I need 2D), or Clipper (which is what Geometry2D pretty much exposes but isn't enough).