def getLoopConvexAddedIndex(around, lastAddedIndex, lastPoint, segment):
 polygonConvexAddedIndex = (len(around) - 1)
 greatestDotProduct = (-9.9)
 for addedIndex in xrange((lastAddedIndex + 1), len(around)):
  addedPoint = around[addedIndex]
  addedSegment = getNormalized((addedPoint - lastPoint))
  if (abs(addedSegment) > 0.0):
   dotProduct = getDotProduct(addedSegment, segment)
   if (dotProduct >= greatestDotProduct):
    greatestDotProduct = dotProduct
    polygonConvexAddedIndex = addedIndex
 return polygonConvexAddedIndex

def getLoopConvexAddedIndex ( around , lastAddedIndex , lastPoint , segment ) : polygonConvexAddedIndex = ( len ( around ) - 1 ) greatestDotProduct = ( - 9.9 ) for addedIndex in xrange ( ( lastAddedIndex + 1 ) , len ( around ) ) : addedPoint = around [ addedIndex ] addedSegment = getNormalized ( ( addedPoint - lastPoint ) ) if ( abs ( addedSegment ) > 0.0 ) : dotProduct = getDotProduct ( addedSegment , segment ) if ( dotProduct >= greatestDotProduct ) : greatestDotProduct = dotProduct polygonConvexAddedIndex = addedIndex return polygonConvexAddedIndex
get polygon convex added index .