コード例 #1
0
ファイル: incremental_dag.py プロジェクト: pepedrog/BCC
 def busca(self, ponto):
     " Retorna o nó folha em que o ponto está "
     if desenha_busca: self.draw()
     for f in self.filhos:
         if (left_on(f.p1, f.p2, ponto) and left_on(f.p2, f.p3, ponto)
                 and left_on(f.p3, f.p1, ponto)):
             if desenha_busca: self.hide()
             return f.busca(ponto)
     if desenha_busca: self.hide()
     return self
コード例 #2
0
ファイル: dcel.py プロジェクト: ygortavela/MAC0331
    def diagonalInCone(self, firstVertex, secondVertex, diagonalEdge):
        i = self.vertexCoordinates(diagonalEdge[0])
        j = self.vertexCoordinates(diagonalEdge[1])
        u = self.vertexCoordinates(firstVertex)
        w = self.vertexCoordinates(secondVertex)

        if (left_on(u, i, w)):
            return left(i, j, u) and left(j, i, w)
        else:
            return not (left_on(i, j, w) and left_on(j, i, u))
コード例 #3
0
ファイル: orelhas.py プロジェクト: pepedrog/BCC
def dentroDoPoligono(u, w, P):
    """ Função que recebe dois vértices u e w do polígono P e retorna se a 
        candidata a diagonal uw está pra dentro do polígono
        (equivalente a função NoCone dos slides)
    """
    prevU = u.prev
    nextU = u.next
    if (left_on(prevU, u, nextU)):
        resposta = (left(u, w, prevU) and left(w, u, nextU))
    else:
        resposta = not (left_on(u, w, nextU) and left_on(w, u, prevU))

    if not resposta:
        uw = Segment(u, w)
        uw.plot("yellow")
        sleep()
        uw.hide()

    return resposta
コード例 #4
0
    def trapContainsVertex(self, vertexPoint):
        if (self.topSuppVertex == vertexPoint):
            return True
        elif (vertexPoint == self.leftEdge[0]) or (vertexPoint == self.leftEdge[1]) or \
             (vertexPoint == self.rightEdge[0]) or (vertexPoint == self.rightEdge[1]):
            return True
        elif (vertexPoint.y <= self.topSuppVertex.y) and \
            ((vertexPoint.y <= self.leftEdge[0].y) and (vertexPoint.y >= self.leftEdge[1].y) and
             (vertexPoint.y <= self.rightEdge[0].y) and (vertexPoint.y >= self.rightEdge[1].y)) and \
            (left_on(self.rightEdge[1].coordinates, self.rightEdge[0].coordinates, vertexPoint.coordinates) and
             not left(self.leftEdge[1].coordinates, self.leftEdge[0].coordinates, vertexPoint.coordinates)):
            return True

        return False
コード例 #5
0
ファイル: convexhull.py プロジェクト: ygortavela/MAC0331
    def __merge(self, startIndex, midIndex, endIndex):
        leftCopy = self.pointList[startIndex:midIndex + 1]
        rightCopy = self.pointList[midIndex + 1:endIndex + 1]

        leftIndex = 0
        rightIndex = 0
        sortIndex = startIndex

        while leftIndex < len(leftCopy) and rightIndex < len(rightCopy):
            if not left_on(self.pointList[0], rightCopy[rightIndex],
                           leftCopy[leftIndex]):
                self.pointList[sortIndex] = leftCopy[leftIndex]
                leftIndex = leftIndex + 1
            elif collinear(self.pointList[0], leftCopy[leftIndex],
                           rightCopy[rightIndex]):
                if dist2(self.pointList[0], leftCopy[leftIndex]) < dist2(
                        self.pointList[0], rightCopy[rightIndex]):
                    self.pointList[sortIndex] = leftCopy[leftIndex]
                    leftIndex = leftIndex + 1
                else:
                    self.pointList[sortIndex] = rightCopy[rightIndex]
                    rightIndex = rightIndex + 1
            else:
                self.pointList[sortIndex] = rightCopy[rightIndex]
                rightIndex = rightIndex + 1

            sortIndex = sortIndex + 1

        while leftIndex < len(leftCopy):
            self.pointList[sortIndex] = leftCopy[leftIndex]
            leftIndex = leftIndex + 1
            sortIndex = sortIndex + 1

        while rightIndex < len(rightCopy):
            self.pointList[sortIndex] = rightCopy[rightIndex]
            rightIndex = rightIndex + 1
            sortIndex = sortIndex + 1
コード例 #6
0
ファイル: lee_preparata.py プロジェクト: pepedrog/BCC
 def __eq__ (self, other):
     return (other != None and self.sup != other.sup and
             left_on (self.a_esq.init, self.a_esq.to, other.sup) and
             right_on (self.a_dir.init, self.a_dir.to, other.sup))
コード例 #7
0
 def __angle(self, u, v, w):
     return not left_on(u.coordinates, v.coordinates, w.coordinates)
コード例 #8
0
ファイル: convexhull.py プロジェクト: ygortavela/MAC0331
 def __rightWrap(self, i, j, k):
     return not left_on(self.pointList[i], self.pointList[j],
                        self.pointList[k])
コード例 #9
0
 def compare_to (self, a, b):
     if(prim.left(b.init, b.to, a.to)):
         return 1
     elif (prim.left_on(b.init, b.to, a.to)):
         return 0
     return -1