def getLoopCentroid(polygonComplex):
 polygonDoubleArea = 0.0
 polygonTorque = 0.0
 for pointIndex in xrange(len(polygonComplex)):
  pointBegin = polygonComplex[pointIndex]
  pointEnd = polygonComplex[((pointIndex + 1) % len(polygonComplex))]
  doubleArea = ((pointBegin.real * pointEnd.imag) - (pointEnd.real * pointBegin.imag))
  doubleCenter = complex((pointBegin.real + pointEnd.real), (pointBegin.imag + pointEnd.imag))
  polygonDoubleArea += doubleArea
  polygonTorque += (doubleArea * doubleCenter)
 torqueMultiplier = (0.3333333333333333 / polygonDoubleArea)
 return (polygonTorque * torqueMultiplier)

def getLoopCentroid ( polygonComplex ) : polygonDoubleArea = 0.0 polygonTorque = 0.0 for pointIndex in xrange ( len ( polygonComplex ) ) : pointBegin = polygonComplex [ pointIndex ] pointEnd = polygonComplex [ ( ( pointIndex + 1 ) % len ( polygonComplex ) ) ] doubleArea = ( ( pointBegin . real * pointEnd . imag ) - ( pointEnd . real * pointBegin . imag ) ) doubleCenter = complex ( ( pointBegin . real + pointEnd . real ) , ( pointBegin . imag + pointEnd . imag ) ) polygonDoubleArea += doubleArea polygonTorque += ( doubleArea * doubleCenter ) torqueMultiplier = ( 0.3333333333333333 / polygonDoubleArea ) return ( polygonTorque * torqueMultiplier )
get the area of a complex polygon using URL .