ear clipping triangulation of simple polygons

Posted By: txesmi

ear clipping triangulation of simple polygons - 03/06/17 10:13

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.


DOWNLOAD
Draw 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!
Posted By: Superku

Re: ear clipping triangulation of simple polygons - 03/06/17 10:27

Very interesting, thanks for sharing!
Posted By: Kartoffel

Re: ear clipping triangulation of simple polygons - 03/06/17 12:17

cool stuff. can be pretty helpful when filling shapes... I might even need this laugh
Posted By: 20BN

Re: ear clipping triangulation of simple polygons - 03/06/17 13:17

thanks for sharing!

it's very useful for pathfinding!!!!!!!!!
Posted By: txesmi

Re: ear clipping triangulation of simple polygons - 03/07/17 05:27

glad of been helpfull wink
Posted By: PadMalcom

Re: ear clipping triangulation of simple polygons - 03/16/17 23:31

Cool, how difficult would it be to extend it to handle holes?
Posted By: txesmi

Re: ear clipping triangulation of simple polygons - 03/18/17 07:20

Originally Posted By: PadMalcom
Cool, how difficult would it be to extend it to handle holes?
As far as I read it is not hard to achieve. It is planned wink
Posted By: Kartoffel

Re: ear clipping triangulation of simple polygons - 03/18/17 14:08

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).
Posted By: 3run

Re: ear clipping triangulation of simple polygons - 05/29/18 15:46

txesmi@ man, you are awesome, just as always! thank you very much for this contribution!
Posted By: txesmi

Re: ear clipping triangulation of simple polygons - 05/30/18 08:41

thanks laugh enjoy!
© 2024 lite-C Forums