def intersect(sx,sy,sz,rad,bx,by,bz,l):
    """
    Determine if a sphere and a box overlap
    Args:
        sx: float for the x postion of the center of the sphere
        sy: float for the y postion of the center of the sphere
        sz: float for the z postion of the center of the sphere
        rad: a float with the raidus of the sphere
        bx: a float with the smallest x value of the box
        by: a float with the smallest y value of the box
        bz: a float with the smallest z value of the box
        l: a float with the side length
    Returns:
        a boolean indicating if they overlap
    """
    # check intersection with the planes that define the box

    xs = (sx <= bx) & ((sx + rad) >= bx)
    xl = (sx >= (bx+l)) & ((sx - rad) <= (bx+l))
    ys = (sy <= by) & ((sy + rad) >= by)
    yl = (sy >= (by+l)) & ((sy - rad) <= (by+l))
    zs = (sz <= bz) & ((sz + rad) >= bz)
    zl = (sz >= (bz+l)) & ((sz - rad) <= (bz+l))

    # check if within a face
    fz = (bx <= sx <= (bx+l)) & (by <= sy <= (by+l))
    fx = (bz <= sz <= (bz+l)) & (by <= sy <= (by+l))
    fy = (bx <= sx <= (bx+l)) & (bz <= sz <= (bz+l))

    # now do some logic
    # if within a face and intersecting a plane return true

    if ((fx & (xs or xl)) or (fy & (ys or yl)) or (fz & (zs or zl))):
        return True
        
    # if within two planes and intersecting two orthogonal planes
    if ((bx <= sx <= (bx+l)) & 
        ((yl & zl) or (yl & zs) or (ys & zl) or (ys & zs))):
        return True
    if ((by <= sy <= (by+l)) & 
        ((xl & zl) or (xl & zs) or (xs & zl) or (xs & zs))):
        return True
    if ((bz <= sz <= (bz+l)) & 
        ((yl & xl) or (yl & xs) or (ys & xl) or (ys & xs))):
        return True

    # if intersecting three planes return true
    if (xs or xl) & (ys or yl) & (zs or zl):
        return True 

    # we got here, the sphere must be outside the box
    return False