#NEWLINE# def triangulate( poly ) : #NEWLINE# #INDENT# "Triangulates poly and returns a list of triangles\n    \n    :Parameters:\n        poly\n            list of points that form an anticlockwise polygon \n            (self-intersecting polygons won't work, results are undefined)\n    " #NEWLINE# triangles = [ ] #NEWLINE# remaining = poly [ : ] #NEWLINE# while ( len ( remaining ) > 2 ) : #NEWLINE# #INDENT# remaining = ( remaining [ 1 : ] + remaining [ : 1 ] ) #NEWLINE# ( ear , remaining ) = _get_ear ( remaining ) #NEWLINE# if ( ear != [ ] ) : #NEWLINE# #INDENT# triangles . append ( ear ) #NEWLINE# #UNINDENT# #UNINDENT# return triangles