def segments_colinear(ab, cd):
    '''
    segments_colinear_2D((a, b), (c, d)) yields True if either a or b is on the line segment (c,d) or
    if c or d is on the line segment (a,b) and the lines are colinear; otherwise yields False. All
    of a, b, c, and d must be (x,y) coordinates or 2xN (x,y) coordinate matrices, or (x,y,z) or 3xN
    matrices.
    '''
    (a,b) = ab
    (c,d) = cd
    ss = [point_on_segment(ab, c), point_on_segment(ab, d),
          point_on_segment(cd, a), point_on_segment(cd, b)]
    return np.sum(ss, axis=0) > 1
segments_colinear_2D((a, b), (c, d)) yields True if either a or b is on the line segment (c,d) or
    if c or d is on the line segment (a,b) and the lines are colinear; otherwise yields False. All
    of a, b, c, and d must be (x,y) coordinates or 2xN (x,y) coordinate matrices, or (x,y,z) or 3xN
    matrices.