def intersection(bb1, bb2):
    """ Calculates the Intersection of two aabb's
    """
    min_w = min(bb1[2], bb2[2])
    min_h = min(bb1[3], bb2[3])
    if bb1[0] < bb2[0]:
        leftbb, rightbb = bb1, bb2
    else:
        leftbb, rightbb = bb2, bb1

    if bb1[1] < bb2[1]:
        topbb, bottombb = bb1, bb2
    else:
        topbb, bottombb = bb2, bb1

    w = min(min_w, max(leftbb[0] + leftbb[2] - rightbb[0], 0))
    h = min(min_h, max(topbb[1] + topbb[3] - bottombb[1], 0))
    return w * h