Esempio n. 1
0
def intersectaBorda(u, w, P):
    """ Função que recebe dois vértices u e w do polígono P e retorna se o 
        segmento uw intersecta alguma aresta de P
        (equivalente a função QuaseDiagonal dos slides)
    """
    borda = P.edges()
    uw = Segment(u, w)
    for aresta in borda:
        aresta.plot('cyan')
        sleep()
        if (u not in aresta.endpoints()) and (w not in aresta.endpoints()):
            if (uw.intersects(aresta)):
                aresta.hide()
                aresta.plot('yellow')
                sleep()
                aresta.hide()
                return True
        aresta.hide()

    return False
def intersects(seg1: Segment, seg2: Segment) -> bool:
    ''' Returns whether two segments intersect or not. '''
    return seg1.intersects(seg2)