def split1d(Astart,Aend,Bstart,Bend):
    """For a 1-d pair of lines A and B:
    given start and end locations,
    produce new set of points for A, split by B.
    
    For example:
    split1d(1,9,3,5)
    splits the line from 1 to 9 into 3 pieces,
    1 to 3
    3 to 5
    and
    5 to 9
    it returns these three pairs and a list of whether
    those points were inside B.
    In this case the list is [False,True,False]
    """
    #five options
    #1 A and B don't intersect. This shouldn't happen
    if (Astart>=Bend) or (Bstart>=Aend):
        #Not sure what to do
        assert False
    #2 B starts first, and ends inside A:
    if (Astart>=Bstart) and (Bend<Aend):
        #return Astart-Bend Bend-Aend
        return [[Astart,Bend],[Bend,Aend]], [True, False]
    #3 B extends beyond limits of A in both directions:
    if (Bstart<=Astart) and (Bend>=Aend):
        #return A
        return [[Astart,Aend]], [True]
    #4 B starts in A and finishes after A
    if (Astart<Bstart) and (Bend>=Aend):
        #return Astart-Bstart Bstart-Aend
        return [[Astart,Bstart],[Bstart,Aend]], [False,True]
    #5 B is inside A
    if (Astart<Bstart) and (Bend<Aend):
        #return Astart-Bstart Bstart-Bend Bend-Aend
        return [[Astart,Bstart],[Bstart,Bend],[Bend,Aend]], [False,True,False]