What is the opposite of polygon triangulation?

After I did the 2D triangulation, some triangles have the same color, and I want to recompile them for drawing into color graphic paths. I believe that if I just draw triangles one by one, some graphic visualizers show the seams between the triangles (at least if smoothing and / or transparency are involved).

So, how do I take a set of (non-overlapping) triangles and create a graphic path that can contain holes and non-overlapping polygons?

Blindly adding triangles to the graphics path actually works very well for filling (although not for stroking, of course), but it does not have the right to export these additional internal points.

+3
source share
1 answer

Remember each triangle as a contour consisting of three vectors going counterclockwise into a chain.

<--^
| /
|/ 
V

So, for all the triangles in your shape, take the union of their contour vectors. If two contour vectors in the union are identical, but go in opposite directions, they cancel each other and are removed from the union.

For example, for two triangles that are side by side, the union is 6 vectors

<--^^
| //|
|// |
VV-->

which comes down to 4 vectors, because the two diagonal vectors in the middle cancel, because they are identical, but work in opposite directions:

<--^
|  |
|  |
V-->

, . , . , .

<-----<-----<-----^
|                 |
|                 |
V     ^----->     ^
|     |     |     |
|     |     |     |
V     <-----V     ^
|                 |
|                 |
V----->----->----->
+6

All Articles