def polygon_area(polygon):
    """Calculates the area of an arbitrary polygon."""
    area = 0.0
    n = len(polygon)
    if n > 0:
        polygon -= polygon[0]
        for j, p1 in enumerate(polygon):
            p2 = polygon[(j+1) % n]
            area += p1[0] * p2[1] - p2[0] * p1[1]
    return 0.5 * area