#NEWLINE# def _get_ear( poly ) : #NEWLINE# #INDENT# count = len ( poly ) #NEWLINE# if ( count < 3 ) : #NEWLINE# #INDENT# return ( [ ] , [ ] ) #NEWLINE# #UNINDENT# if ( count == 3 ) : #NEWLINE# #INDENT# return ( poly , [ ] ) #NEWLINE# #UNINDENT# for i in range ( count ) : #NEWLINE# #INDENT# ia = ( ( i - 1 ) % count ) #NEWLINE# ib = i #NEWLINE# ic = ( ( i + 1 ) % count ) #NEWLINE# a = poly [ ia ] #NEWLINE# b = poly [ ib ] #NEWLINE# c = poly [ ic ] #NEWLINE# if _is_corner ( a , b , c ) : #NEWLINE# #INDENT# valid = True #NEWLINE# for j in range ( count ) : #NEWLINE# #INDENT# if ( not ( j in ( ia , ib , ic ) ) ) : #NEWLINE# #INDENT# p = poly [ j ] #NEWLINE# if _point_in_triangle ( p , a , b , c ) : #NEWLINE# #INDENT# valid = False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if valid : #NEWLINE# #INDENT# remaining = [ ] #NEWLINE# for j in range ( count ) : #NEWLINE# #INDENT# if ( j != ib ) : #NEWLINE# #INDENT# remaining . append ( poly [ j ] ) #NEWLINE# #UNINDENT# #UNINDENT# return ( [ a , b , c ] , remaining ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( [ ] , [ ] )