def intersect_segs(seg1, seg2): """ Tries intersecting coherent segments. If there is not intersection, returns None. """ if len(seg1) == 2 and len(seg2) == 2: return intersect_lines(seg1[0], seg1[-1], seg2[0], seg2[-1]) else: if len(seg1) == 2: path1 = [seg1[0], [ seg1[-1], ], sk2const.CURVE_OPENED] else: path1 = [ seg1[-4], [ [seg1[-3], seg1[-2], seg1[-1], sk2const.NODE_CUSP], ], sk2const.CURVE_OPENED ] if len(seg2) == 2: path2 = [seg2[0], [ seg2[-1], ], sk2const.CURVE_OPENED] else: path2 = [ seg2[0], [ [seg2[1], seg2[2], seg2[3], sk2const.NODE_CUSP], ], sk2const.CURVE_OPENED ] return intersect_segments(path1, path2)
def intersect_segs(seg1, seg2): """ Tries intersecting coherent segments. If there is not intersection, returns None. """ if len(seg1) == 2 and len(seg2) == 2: return intersect_lines(seg1[0], seg1[-1], seg2[0], seg2[-1]) else: if len(seg1) == 2: path1 = [seg1[0], [seg1[-1], ], sk2_const.CURVE_OPENED] else: path1 = [seg1[-4], [[seg1[-3], seg1[-2], seg1[-1], sk2_const.NODE_CUSP], ], sk2_const.CURVE_OPENED] if len(seg2) == 2: path2 = [seg2[0], [seg2[-1], ], sk2_const.CURVE_OPENED] else: path2 = [seg2[0], [[seg2[1], seg2[2], seg2[3], sk2_const.NODE_CUSP], ], sk2_const.CURVE_OPENED] return intersect_segments(path1, path2) return None