def rotatePolygon(polygon, theta, origin=None):
if origin is None:<EOL><INDENT>origin = np.mean(polygon, axis=<NUM_LIT:0>, dtype=polygon.dtype)<EOL><DEDENT>polygon -= origin<EOL>for n, corner in enumerate(polygon):<EOL><INDENT>polygon[n] = corner[<NUM_LIT:0>] * np.cos(theta) - corner[<NUM_LIT:1>] * np.sin(theta), corner[<EOL><NUM_LIT:0>] * np.sin(theta) + corner[<NUM_LIT:1>] * np.cos(theta)<EOL><DEDENT>polygon += origin<EOL>return polygon<EOL>
Rotates the given polygon around the origin or if not given it's center of mass

    polygon: np.array( (x1,y1), (...))
    theta: rotation clockwise in RADIAN
    origin = [x,y] - if not given set to center of gravity

    returns: None