def _maxDistInDirection(area, beginPos, angle):
    angle = angle % 360
    rad = math.radians(angle)
    x, y = beginPos
    top = area.getBbox()[0][1]
    left = area.getBbox()[0][0]
    bottom = area.getBbox()[1][1]
    right = area.getBbox()[1][0]
    if 0 < angle < 180:
        maxDistY = (bottom - y) / math.sin(rad)
    elif 180 < angle < 360:
        maxDistY = (top-y) / math.sin(rad)
    else:
        maxDistY = float('inf')

    if 90 < angle < 270:
        maxDistX = (left - x) / math.cos(rad)
    elif 270 < angle or angle < 90:
        maxDistX = (right - x) / math.cos(rad)
    else:
        maxDistX = float('inf')

    return min(maxDistX, maxDistY)
dataset/ETHPy150Open teroc/Otero/opentestrobot/guielements.py/_maxDistInDirection/original