def overlap_data(a, b):
    """
        Given that a and b overlap, extracts the shortest direction to move
        along and the penetration.

        returns -> normal, depth
        (normal points from a)
    """
    # This code is based on SAT (the shortest distance is along one normal).
    delta = a.centerx - b.centerx, a.centery - b.centery
    span = (a.width + b.width) / 2, (a.height + b.height) / 2

    # Pick the smallest overlapping axis
    overlap = span[0] - abs(delta[0]), span[1] - abs(delta[1])
    depth = min(overlap)

    # Inline helper
    sign = lambda x: 1 if x > 0 else -1

    if abs(overlap[0]) < abs(overlap[1]):
        normal = sign(delta[0]), 0
    else:
        normal = 0, sign(delta[1])

    return normal, depth