def calc_bounding_box_intersection(a, b, p, slope):
    """Calculate the intersection of a line (defined by p and slope) and the bounding box (defined by a and b)

    Parameters
    ----------
    a: tuple
        left lower corner of the bounding box.
    b: tuple
        right higher corner of the bounding box.
    p: tuple
        point one the line.
    slope: float
        slope of the line which goes through p.

    Returns
    -------
    array
        new_points: An array with the 2 points which intersect the bounding box.
    """
    new_points = []
    offset = p[1][0] - (slope * p[0][0])

    # calc left edge intersection
    y1 = slope * a[0] + offset
    if a[1] <= y1 <= b[1]:
        new_points.append((int(a[0]), int(y1)))

    # calc right edge intersection
    y2 = slope * b[0] + offset
    if a[1] <= y2 <= b[1]:
        new_points.append((int(b[0]), int(y2)))

    # calc top edge intersection
    x1 = (a[1] - offset) / slope
    if a[0] <= x1 <= b[0]:
        new_points.append((int(x1), int(a[1])))

    # calc bottom edge intersection
    x2 = (b[1] - offset) / slope
    if a[0] <= x2 <= b[0]:
        new_points.append((int(x2), int(b[1])))

    return new_points