|
ear clipping triangulation of simple polygons
#464687
03/06/17 10:13
03/06/17 10:13
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
OP
Serious User
|
OP
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Hi! A simple polygon has no shared vertex, crossing edges or holes and it is sorted counter-clockwise on right handed coordinates. The algorithm takes three contiguos points, checks the angle between segments and checks if any other point is not contained by the triangle in order to set it as a valid triangle. This method is far from been the fastest but it is pretty easy to follow. DOWNLOADDraw a polygon by mouse left button and triangulate it by mouse right button. You can watch the process by uncommenting SHOW_BUILT definition on 'simple_polygon.h' Enjoy!
|
|
|
Re: ear clipping triangulation of simple polygons
[Re: txesmi]
#464943
03/18/17 14:08
03/18/17 14:08
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Another useful feature would be selecting clockwise/counter-clockwise triangle creation automatically. This should work by adding the relative angles between all lines (of the outline) and checking if the result is greater or less than 0. (theoretically only +360° or -360° are possible).
POTATO-MAN saves the day! - Random
|
|
|
|