Exemple #1
0
    def transforme_coord_to_(self, c):
        p_2D = np.append(self.__p.coord, 0)[:, np.newaxis]
        new_p_2D = np.dot(c, p_2D)
        new_p_1D = new_p_2D.transpose().squeeze()
        new_p = np.delete(new_p_1D, 3, 0)
        self.__p = Point(new_p[0], new_p[1], new_p[2])

        dr_2D = np.append(self.__dr, 1)[:, np.newaxis] #TODO tem um erro aqui, 'self.__dr' está sendo visto como um Point, quando deveria ser um vetor (np.array)
        new_dr_2D = np.dot(c, dr_2D)
        new_dr_1D = new_dr_2D.transpose().squeeze()
        new_dr = np.delete(new_dr_1D, 3, 0)
        self.__dr = Point(new_dr[0], new_dr[1], new_dr[2])
Exemple #2
0
 def getPath(self, start,  goal):
     self.connectToGraph(start);
     self.connectToGraph(goal);
     openset = minHeap(self.Length,self.Width)
     g_score =[]
     f_score =[]
     came_from=[]
     close_set=[]
     for i in xrange(self.Length):
         g_score.append([0]*self.Width)
         f_score.append([0]*self.Width)
         came_from.append([None]*self.Width)
         close_set.append([False]*self.Width)
     f_score[start.Y][start.X] = g_score[start.Y][start.X ] + self.heuristic_cost_estimate(start, goal);
     openset.add(f_score[start.Y][start.X], start);
     neighbors=None;
     while openset.count() != 0:
         current = openset.removemin();
         if current==goal:
             return self.reconstruct_path(came_from, goal, start);
         close_set[current.Y][current.X] = True;
         neighbors = self.getNeighbours(current);
         for neighbor in neighbors.list:
             tentative_g_score = g_score[current.Y][current.X] + Point.distantTo(current, neighbor);
             if close_set[neighbor.Y][neighbor.X]:
                 if tentative_g_score >= g_score[neighbor.Y][neighbor.X]:
                     continue;
             if not openset.Contains(neighbor) or tentative_g_score < g_score[neighbor.Y][neighbor.X]:
                 came_from[neighbor.Y][neighbor.X] = current;
                 g_score[neighbor.Y][neighbor.X] = tentative_g_score;
                 f_score[neighbor.Y][neighbor.X] = g_score[neighbor.Y][neighbor.X] + self.heuristic_cost_estimate(neighbor, goal);
                 if not openset.Contains(neighbor):
                     openset.add(f_score[neighbor.Y][neighbor.X], neighbor);
     return None;
Exemple #3
0
    def input(self):
        from Parser import parseTupleList
        from DataStructure.Point import Point

        for s in parseTupleList(open(self.inputPath)):
            tuples = s[0]
            yield [Point(pair[0], pair[1]) for pair in tuples],
Exemple #4
0
 def get_p(self, i, j):
     if self.tam / self.n_lin >= self.tam / self.n_col:
         var = self.tam / self.n_col
     else:
         var = self.tam / self.n_lin
     x = -self.tam / 2 + var * (1 + 2 * j) / 2
     y = self.tam / 2 - var * (1 + 2 * i) / 2
     z = Z_PLACA
     return Point(x, y, z)
Exemple #5
0
 def __init__(self, centro: Point, vetor, aresta, material=None, cor=None):
     self.__centro = centro
     self.__n = vetor / np.linalg.norm(vetor)
     self.__aresta = aresta
     self.__lista_vertices = calc_vertices(centro, aresta)
     self.__lista_arestas = calc_arestas(self.lista_vertices)
     self.__lista_faces = calc_faces(self.lista_vertices)
     self.__material = material
     self.__cor = cor
     self.__cluster = Sphere(
         Point(centro.x, centro.y + aresta / 2, centro.z),
         aresta * np.sqrt(3) / 2, material, cor)
Exemple #6
0
    def transforme_coord_to_(self, c):
        centro_2D = np.append(self.centro.coord, 0)[:, np.newaxis]
        new_centro_2D = np.dot(c, centro_2D)
        new_centro_1D = new_centro_2D.transpose().squeeze()
        new_centro = np.delete(new_centro_1D, 3, 0)
        self.__centro = Point(new_centro[0], new_centro[1], new_centro[2])

        u_2D = np.append(self.u, 1)[:, np.newaxis]
        new_u_2D = np.dot(c, u_2D)
        new_u_1D = new_u_2D.transpose().squeeze()
        new_u = np.delete(new_u_1D, 3, 0)
        self.__u = new_u
Exemple #7
0
    def transforme_coord_to_(self, c):
        # print("teste ====================")
        # print("antes: ", self.centro.coord, self.centro.coord.shape)

        centro_2D = np.append(self.centro.coord, 0)[:, np.newaxis]
        new_centro_2D = np.dot(c, centro_2D)
        new_centro_1D = new_centro_2D.transpose().squeeze()
        new_centro = np.delete(new_centro_1D, 3, 0)
        self.__centro = Point(new_centro[0], new_centro[1], new_centro[2])

        n_2D = np.append(self.n, 1)[:, np.newaxis]
        new_n_2D = np.dot(c, n_2D)
        new_n_1D = new_n_2D.transpose().squeeze()
        new_n = np.delete(new_n_1D, 3, 0)
        self.__n = new_n
Exemple #8
0
    def transforme_coord_to_(self, c):
        centro_2D = np.append(self.centro.coord, 0)[:, np.newaxis]
        new_centro_2D = np.dot(c, centro_2D)
        new_centro_1D = new_centro_2D.transpose().squeeze()
        new_centro = np.delete(new_centro_1D, 3, 0)
        self.__centro = Point(new_centro[0], new_centro[1], new_centro[2])

        n_2D = np.append(self.n, 1)[:, np.newaxis]
        new_n_2D = np.dot(c, n_2D)
        new_n_1D = new_n_2D.transpose().squeeze()
        new_n = np.delete(new_n_1D, 3, 0)
        self.__n = new_n

        self.__lista_vertices = calc_vertices(self.centro, self.aresta)
        self.__lista_arestas = calc_arestas(self.lista_vertices)
        self.__lista_faces = calc_faces(self.lista_vertices)
Exemple #9
0
def calc_vertices(centro, aresta):
    vertices = []
    v0 = Point(centro.x + (aresta / 2), centro.y, centro.z + (aresta / 2), "0")
    v1 = Point(centro.x + (aresta / 2), centro.y, centro.z - (aresta / 2), "1")
    v2 = Point(centro.x - (aresta / 2), centro.y, centro.z - (aresta / 2), "2")
    v3 = Point(centro.x - (aresta / 2), centro.y, centro.z + (aresta / 2), "3")
    v4 = Point(centro.x + (aresta / 2), centro.y + aresta,
               centro.z + (aresta / 2), "4")
    v5 = Point(centro.x + (aresta / 2), centro.y + aresta,
               centro.z - (aresta / 2), "5")
    v6 = Point(centro.x - (aresta / 2), centro.y + aresta,
               centro.z - (aresta / 2), "6")
    v7 = Point(centro.x - (aresta / 2), centro.y + aresta,
               centro.z + (aresta / 2), "7")

    vertices.append(v0)
    vertices.append(v1)
    vertices.append(v2)
    vertices.append(v3)
    vertices.append(v4)
    vertices.append(v5)
    vertices.append(v6)
    vertices.append(v7)
    return vertices
Exemple #10
0
 def heuristic_cost_estimate(self, p1, p2):
     return Point.distantTo(p1, p2)
Exemple #11
0
 def transforme_coord_to_(self, c):
     p_2D = np.append(self.__ppont.coord, 0)[:, np.newaxis]
     new_p_2D = np.dot(c, p_2D)
     new_p_1D = new_p_2D.transpose().squeeze()
     new_p = np.delete(new_p_1D, 3, 0)
     self.__ppont = Point(new_p[0], new_p[1], new_p[2])
Exemple #12
0
sys.setrecursionlimit(RECURSION_LIMIT)

# Posicionamento da Placa furada =================================
num_furos = 100  # número de furos por linha. Define a resolução da tela
tamanho = 10  # medida da aresta da placa em unidades de coordenada
placa = Panel(tamanho, num_furos, num_furos)
"""O centro do painel tem coordenada [0,0,z]
    deste modo os vertices tem coord:
    [-tam/2, tam/2, z]  ______ [tam/2,  tam/2, z]
                       |  .  |
    [-tam/2,-tam/2, z] |_____| [tam/2, -tam/2, z]
"""

# Posicionamento de Câmera =======================================
viewer = Point(0, 0, 0)  # Coordeanadas do observador
look_at = Point(0, 0, -10)  # Ponto q define a direção da camera
view_up = Point(0, 10, -10)  # Ponto que define o plano sagital
camera = camera_init_(viewer.coord, look_at.coord, view_up.coord)

# CENÁRIO ========================================================
mat_teste = Material(0, 0, 0)  #TODO definir parametros corretos do material
objetos = []

cubo1 = Cube(Point(0, -2, -20), Point(0, 1, 0).coord, 6, mat_teste, "1")
cubo2 = Cube(Point(0, 4, -20), Point(0, 1, 0).coord, 6, mat_teste, "2")
cubo3 = Cube(Point(0, 10, -20), Point(0, 1, 0).coord, 6, mat_teste, "3")
cone = Cone(Point(0, 0, -10), Point(0, 1, 0).coord, 2, 6, mat_teste, "_")
cilindro = Cylinder(Point(0, -2, -10),
                    Point(0, 1, 0).coord, 0.5, 2, mat_teste, "H")
esfera = Sphere(Point(0, 6.5, -10), 0.5, mat_teste, "o")