def __init__(self, base, anguloAzimute, angulo): Vector3D.__init__(self, base.x, base.y, base.z) self.anguloAzimute = anguloAzimute self.angulo = angulo self.vx = 0 self.vy = 0 self.vz = 0 self.vZInicial = 0 self.tempoVoando = 0 self.massa = 1.565 self.velocidade = 1175 self.alcance = 4000 self.atirada = False
def __init__(self, x, y, z): Vector3D.__init__(self, x, y, z) self._tipo = randint(1, 2) # Sorteia entre tipo 1 e 2 # self._tipo = 2 # <================================================================================ self._velocidade = 0 self._vx = 0 self._vy = 0 # Inicializa parametros self.inicializaPosicao() self.inicializaVelocidade() # Inicializa a velocidade de acordo com o tipo self._desiste = randint(1, 10) # self._desiste = 0 #<=============================================================================== self._jaDesistiu = 0 self._tempoVoando = 0 self._tempoMudanca = numpy.random.normal(7.5, 1)
def v_dot(self, vector): """ calculate dot product of Matrix3D with inverted(Vector3D) | a1 | b1 | c1 | d1 | | x | | a1*x + b1*y + c1*z + d1*h | | a2 | b2 | c2 | d2 | . | y | = | a2*x + b2*y + c2*z + d2*h | | a3 | b3 | c3 | d3 | | z | | a3*x + b3*y + c3*z + d3*h | | a4 | b4 | c4 | d4 | | h | | a4*x + b4*y + c4*z + d4*h | """ assert isinstance(vector, Vector3D) ret_data = [0, 0, 0, 0] for index in range(4): row_vec = Vector3D.from_list(self.__data[index]) ret_data[index] = row_vec.dot(vector) return Vector3D.from_list(ret_data)
def test_rot_matrices(self): m = Matrix3D.get_rot_x_matrix(100) assert m.dot(Matrix3D.identity()) == m m = Matrix3D.get_rot_y_matrix(100) assert m.dot(Matrix3D.identity()) == m m = Matrix3D.get_rot_z_matrix(100) assert m.dot(Matrix3D.identity()) == m # rotate vector only in x-axis around x - nothing should happen v1 = Vector3D(1, 0, 0, 1) assert Matrix3D.get_rot_x_matrix(100).v_dot(v1) == v1 v1 = Vector3D(0, 1, 0, 1) assert Matrix3D.get_rot_y_matrix(100).v_dot(v1) == v1 v1 = Vector3D(0, 0, 1, 1) assert Matrix3D.get_rot_z_matrix(100).v_dot(v1) == v1 # rotate vectors really v1 = Vector3D(1.0, 0.0, 0.0, 1.0) # 90 degrees or pi/2 real_v = Matrix3D.get_rot_z_matrix(math.pi/2).v_dot(v1) test_v = Vector3D.from_list([0.000000, 1.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # 180 degrees real_v = Matrix3D.get_rot_z_matrix(math.pi).v_dot(v1) test_v = Vector3D.from_list([-1.000000, 0.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # 270 degrees real_v = Matrix3D.get_rot_z_matrix(math.pi + math.pi/2).v_dot(v1) test_v = Vector3D.from_list([0.000000, -1.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # 360 degrees real_v = Matrix3D.get_rot_z_matrix(2 * math.pi).v_dot(v1) test_v = Vector3D.from_list([1.000000, 0.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # rotate around Y-Axis about 180 degrees real_v = Matrix3D.get_rot_y_matrix(math.pi).v_dot(v1) test_v = Vector3D.from_list([-1.000000, 0.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # rotate y:90 and x:90 -> (0, 1, 0, 1) real_v = Matrix3D.get_rot_y_matrix(math.pi/2).v_dot(v1) test_v = Vector3D.from_list([0.000000, 0.000000, -1.000000, 1.000000]) assert real_v.nearly_equal(test_v) real_v = Matrix3D.get_rot_x_matrix(math.pi/2).v_dot(real_v) test_v = Vector3D.from_list([0.000000, 1.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # and this is the combined version rot_y = Matrix3D.get_rot_y_matrix(math.pi/2) print "rotation around y:\n", rot_y rot_x = Matrix3D.get_rot_x_matrix(math.pi/2) print "rotation around x:\n", rot_x rot_z = Matrix3D.get_rot_z_matrix(math.pi/2) print "rotation around z:\n", rot_z rot_m = rot_x.dot(rot_y.dot(rot_z)) print "combined rotation matrix:\n", rot_m real_v = rot_m.v_dot(v1) print "resulting vector:", real_v test_v = Vector3D.from_list([0.000000, 1.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v)
def dot(self, other): """ return dot product of these to 4x4 matrices Matrix A : self Matrix B : other TODO: find a way to describe this in short terms | a11 | a12 | a13 | a14 | | b11 | b12 | b13 | b14 | | row[1].col[1] row[1].col[2] ... ... | | a21 | a22 | a23 | a24 | . | b21 | b22 | b23 | b24 | = | row[2].col[1] row[2].col[2] ... ... | | a31 | a32 | a33 | a34 | | b31 | b32 | b33 | b34 | | ... ... | | a41 | a42 | a43 | a44 | | b41 | b42 | b43 | b44 | | | """ assert isinstance(other, Matrix3D) ret_matrix = self.zeros() for rownum in range(4): row_vec = Vector3D.from_list(self.row(rownum)) for colnum in range(4): col_vec = Vector3D.from_list(other.col(colnum)) ret_matrix[rownum][colnum] = row_vec.dot(col_vec) return ret_matrix
def setup_operation(self, op): ret = Oplist() # West wall loc = Location(self, Vector3D(-0.5, 3.5, 0)) loc.bbox = Vector3D(0.5, 4, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North wall loc = Location(self, Vector3D(-0.5, 7, 0)) loc.bbox = Vector3D(8, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East wall loc = Location(self, Vector3D(7, -0.5, 0)) loc.bbox = Vector3D(0.5, 8, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(-4, 0, -3)) loc.bbox = Vector3D(14, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # West wall loc = Location(self, Vector3D(-4, 0, -3)) loc.bbox = Vector3D(0.2, 5, -4) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North wall loc = Location(self, Vector3D(-4, 0, -6.8)) loc.bbox = Vector3D(14, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East wall loc = Location(self, Vector3D(9.8, 0, 3)) loc.bbox = Vector3D(0.2, 5, -10) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # West annex wall loc = Location(self, Vector3D(4, 0, 3)) loc.bbox = Vector3D(0.2, 5, -6) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # South annex wall loc = Location(self, Vector3D(4, 0, 3)) loc.bbox = Vector3D(6, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(2, -2, 0)) loc.bbox = Vector3D(8, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # West wall with door loc = Location(self, Vector3D(2, -2, 0)) loc.bbox = Vector3D(0.5, 2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(2, 4, 0)) loc.bbox = Vector3D(0.5, 10, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # North wall loc = Location(self, Vector3D(2, 13.5, 0)) loc.bbox = Vector3D(12, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # East walls loc = Location(self, Vector3D(9.5, -2, 0)) loc.bbox = Vector3D(0.5, 7, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # South facing segment of east wall loc = Location(self, Vector3D(10, 2, 0)) loc.bbox = Vector3D(4, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(13.5, 2, 0)) loc.bbox = Vector3D(0.5, 2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # Door here loc = Location(self, Vector3D(13.5, 6, 0)) loc.bbox = Vector3D(0.5, 8, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # Internal walls loc = Location(self, Vector3D(2, 4, 0)) loc.bbox = Vector3D(6, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(7.5, 4, 0)) loc.bbox = Vector3D(0.5, 7, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(0.5, -0.5, 0)) loc.bbox = Vector3D(8, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # West wall with door loc = Location(self, Vector3D(0.5, -0.5, 0)) loc.bbox = Vector3D(0.5, 2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(0.5, 3.5, 0)) loc.bbox = Vector3D(0.5, 4, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # North wall loc = Location(self, Vector3D(0.5, 7, 0)) loc.bbox = Vector3D(8, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # North outer wall loc = Location(self, Vector3D(2.5, 11, 0)) loc.bbox = Vector3D(6, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # East wall with door loc = Location(self, Vector3D(8, -0.5, 0)) loc.bbox = Vector3D(0.5, 2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(8, 3.5, 0)) loc.bbox = Vector3D(0.5, 8, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) return ret
canvas.focus_set() canvas.bind("<Key>", clavier) canvas.create_line(60, 60, 90, 60) operations = [] operations.append(Operation("Ir", [1, 2], 1, 0.7, 0.2)) operations.append(Operation("Il", [0, 2], 0, 0.7, 0.0, 0, 1)) operations.append(Operation("Q1", [3, 4], 0, 0.6, 0.2)) operations.append(Operation("Q2", [3, 2], 1, 0.5, 0.2)) operations.append(Operation("Q3", [3, 2], 0, 0.5, 0.2)) operations.append(Operation("T", [], 1, 0.5, 0.2, 0)) points = [] a = 600 ra = 60 points.append( Vector3D(0 + ra * (random() - 0.5), 0 + ra * (random() - 0.5))) points.append( Vector3D(a + ra * (random() - 0.5), 0 + ra * (random() - 0.5))) points.append( Vector3D(a + ra * (random() - 0.5), a + ra * (random() - 0.5))) points.append( Vector3D(0 + ra * (random() - 0.5), a + ra * (random() - 0.5))) celMod = Model(points, operations) celMod.draw(canvas) canvas.pack() fenetre.mainloop()
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(1, -1, 0)) loc.bbox = Vector3D(10, 0.2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # West wall loc = Location(self, Vector3D(1, -1, 0)) loc.bbox = Vector3D(0.2, 6, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(1, 7, 0)) loc.bbox = Vector3D(0.2, 6, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # North wall with door loc = Location(self, Vector3D(1, 12.8, 0)) loc.bbox = Vector3D(4, 0.2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(7, 12.8, 0)) loc.bbox = Vector3D(4, 0.2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # East wall loc = Location(self, Vector3D(10.8, -1, 0)) loc.bbox = Vector3D(0.2, 14, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # Outer area # South wall loc = Location(self, Vector3D(-0.5, -0.5, 0)) loc.bbox = Vector3D(4, 0.5, 1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # Left of entrance walls loc = Location(self, Vector3D(-0.5, 3.5, 0)) loc.bbox = Vector3D(2, 0.5, 1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(-0.5, 3.5, 0)) loc.bbox = Vector3D(0.5, 4, 1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # Full height walls loc = Location(self, Vector3D(-0.5, 7.5, 0)) loc.bbox = Vector3D(0.5, 4, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # Main structure # South wall loc = Location(self, Vector3D(3.5, -0.5, 0)) loc.bbox = Vector3D(8, 0.5, 1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # West wall with door loc = Location(self, Vector3D(3.5, -0.5, 0)) loc.bbox = Vector3D(0.5, 2, 1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(3.5, 3.5, 0)) loc.bbox = Vector3D(0.5, 8, 1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North wall loc = Location(self, Vector3D(-0.5, 11, 0)) loc.bbox = Vector3D(12, 0.5, 1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East wall with door loc = Location(self, Vector3D(11, -0.5, 0)) loc.bbox = Vector3D(0.5, 2, 1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(11, 3.5, 0)) loc.bbox = Vector3D(0.5, 8, 1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # Interior wall loc = Location(self, Vector3D(7.5, 4.5, 0)) loc.bbox = Vector3D(4, 0.5, 1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall with door loc = Location(self, Vector3D(-1, 0, -1)) loc.bbox = Vector3D(6, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(9, 0, -1)) loc.bbox = Vector3D(4, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # West wall with door loc = Location(self, Vector3D(-1, 0, -1)) loc.bbox = Vector3D(0.5, 5, -2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(-1, 0, -7)) loc.bbox = Vector3D(0.5, 5, -4) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North facing section loc = Location(self, Vector3D(-1, 0, -10.5)) loc.bbox = Vector3D(6, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # Remaining west facing section loc = Location(self, Vector3D(5, 0, -7)) loc.bbox = Vector3D(0.5, 5, -10) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North wall loc = Location(self, Vector3D(5, 0, -16.5)) loc.bbox = Vector3D(8, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East wall with door loc = Location(self, Vector3D(12.5, 0, -1)) loc.bbox = Vector3D(0.5, 5, -4) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(12.5, 0, -7)) loc.bbox = Vector3D(0.5, 5, -10) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(-0.5,-0.5,0)) loc.bbox = Vector3D(8,0.2,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) # West wall with door loc = Location(self, Vector3D(-0.5,-0.5,0)) loc.bbox = Vector3D(0.2,2,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) loc = Location(self, Vector3D(-0.5,3.5,0)) loc.bbox = Vector3D(0.2,12,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) # North wall with door loc = Location(self, Vector3D(-0.5,15.3,0)) loc.bbox = Vector3D(4,0.2,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) loc = Location(self, Vector3D(3.5,15.3,0)) loc.bbox = Vector3D(12,0.2,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) # East wall loc = Location(self, Vector3D(15.3,7.5,0)) loc.bbox = Vector3D(0.2,8,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) # Interior wall loc = Location(self, Vector3D(7.3,-0.5,0)) loc.bbox = Vector3D(0.2,14,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) # Interior wall with door loc = Location(self, Vector3D(7.3,7.5,0)) loc.bbox = Vector3D(4.2,0.2,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) loc = Location(self, Vector3D(11.5,7.5,0)) loc.bbox = Vector3D(4,0.2,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) # South fences loc = Location(self, Vector3D(7.5,-0.5,0)) loc.bbox = Vector3D(2,0.1,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) loc = Location(self, Vector3D(11.5,-0.5,0)) loc.bbox = Vector3D(4,0.1,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) # East fences loc = Location(self, Vector3D(15.4,-0.5,0)) loc.bbox = Vector3D(0.1,3,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) loc = Location(self, Vector3D(15.4,4.5,0)) loc.bbox = Vector3D(0.1,3,5) ret.append(Operation("create",Entity(name='wall',parents=['wall'],location=loc),to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall with door loc = Location(self, Vector3D(2, 0, 2)) loc.bbox = Vector3D(2, 5, -0.5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) loc = Location(self, Vector3D(8, 0, 2)) loc.bbox = Vector3D(2, 5, -0.5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # West wall loc = Location(self, Vector3D(2, 0, 2)) loc.bbox = Vector3D(0.5, 5, -16) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # East wall loc = Location(self, Vector3D(10, 0, 2)) loc.bbox = Vector3D(0.5, 5, -16) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # North wall loc = Location(self, Vector3D(2, 0, -13.5)) loc.bbox = Vector3D(8, 5, -0.5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # Internal wall loc = Location(self, Vector3D(2, 0, -6)) loc.bbox = Vector3D(4, 5, -0.5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # Internal short wall by stairs loc = Location(self, Vector3D(8, 0, -6)) loc.bbox = Vector3D(2, 0.5, -0.5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(0.5,-1.5,0)) loc.bbox = Vector3D(10,0.5,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # West wall with door loc = Location(self, Vector3D(0.5,-1.5,0)) loc.bbox = Vector3D(0.5,2,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) loc = Location(self, Vector3D(0.5,2.5,0)) loc.bbox = Vector3D(0.5,10,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # North wall loc = Location(self, Vector3D(0.5,12,0)) loc.bbox = Vector3D(10,0.5,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # East walls - FIXME There is a door in this first wall loc = Location(self, Vector3D(10,-1.5,0)) loc.bbox = Vector3D(0.5,8,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) loc = Location(self, Vector3D(7.5,6,0)) loc.bbox = Vector3D(3,0.5,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) loc = Location(self, Vector3D(8,6.5,0)) loc.bbox = Vector3D(0.5,6,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # Pillar loc = Location(self, Vector3D(10,9.5,0)) loc.bbox = Vector3D(0.5,0.5,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(1.5, -1.5, 0)) loc.bbox = Vector3D(10, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # West wall with door loc = Location(self, Vector3D(1.5, -1.5, 0)) loc.bbox = Vector3D(0.5, 2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(1.5, 2.5, 0)) loc.bbox = Vector3D(0.5, 12, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # North wall loc = Location(self, Vector3D(1.5, 14, 0)) loc.bbox = Vector3D(8, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # East wall with door loc = Location(self, Vector3D(11, -1.5, 0)) loc.bbox = Vector3D(0.5, 2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(11, 2.5, 0)) loc.bbox = Vector3D(0.5, 4, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(9, 6.5, 0)) loc.bbox = Vector3D(4, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(9, 6.5, 0)) loc.bbox = Vector3D(0.5, 16, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall with door loc = Location(self, Vector3D(0.5,-0.5,0)) loc.bbox = Vector3D(2,0.5,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) loc = Location(self, Vector3D(3.5,-0.5,0)) loc.bbox = Vector3D(6,0.5,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # West wall with door loc = Location(self, Vector3D(0.5,-0.5,0)) loc.bbox = Vector3D(0.5,10,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) loc = Location(self, Vector3D(0.5,11.5,0)) loc.bbox = Vector3D(0.5,2,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # North wall loc = Location(self, Vector3D(0.5,13,0)) loc.bbox = Vector3D(8,0.5,5) # East wall sections with door loc = Location(self, Vector3D(10,-0.5,0)) loc.bbox = Vector3D(0.5,2,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) loc = Location(self, Vector3D(10,3.5,0)) loc.bbox = Vector3D(0.5,4,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) # North facing section loc = Location(self, Vector3D(6,7,0)) loc.bbox = Vector3D(4.5,0.5,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) loc = Location(self, Vector3D(6,7.5,0)) loc.bbox = Vector3D(0.5,6,5) ret.append(Operation("create",Entity(name='wall',parent='wall',location=loc),to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(2, 0, 2)) loc.bbox = Vector3D(8, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # West wall with door loc = Location(self, Vector3D(2, 0, 2)) loc.bbox = Vector3D(0.5, 5, -2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(2, 0, -4)) loc.bbox = Vector3D(0.5, 5, -10) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North wall loc = Location(self, Vector3D(2, 0, -13.5)) loc.bbox = Vector3D(12, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East walls loc = Location(self, Vector3D(9.5, 0, 2)) loc.bbox = Vector3D(0.5, 5, -7) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # South facing segment of east wall loc = Location(self, Vector3D(10, 0, -2)) loc.bbox = Vector3D(4, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(13.5, 0, -2)) loc.bbox = Vector3D(0.5, 5, -2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # Door here loc = Location(self, Vector3D(13.5, 0, -6)) loc.bbox = Vector3D(0.5, 5, -8) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # Internal walls loc = Location(self, Vector3D(2, 0, -4)) loc.bbox = Vector3D(6, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(7.5, 0, -4)) loc.bbox = Vector3D(0.5, 5, -7) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(1, 0, 1)) loc.bbox = Vector3D(10, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # West wall loc = Location(self, Vector3D(1, 0, 1)) loc.bbox = Vector3D(0.2, 5, -6) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(1, 0, -7)) loc.bbox = Vector3D(0.2, 5, -6) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North wall with door loc = Location(self, Vector3D(1, 0, -12.8)) loc.bbox = Vector3D(4, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(7, 0, -12.8)) loc.bbox = Vector3D(4, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East wall loc = Location(self, Vector3D(10.8, 0, 1)) loc.bbox = Vector3D(0.2, 5, -14) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(1.5, 0, 1.5)) loc.bbox = Vector3D(10, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # West wall with door loc = Location(self, Vector3D(1.5, 0, 1.5)) loc.bbox = Vector3D(0.5, 5, -2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(1.5, 0, -2.5)) loc.bbox = Vector3D(0.5, 5, -12) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North wall loc = Location(self, Vector3D(1.5, 0, -14)) loc.bbox = Vector3D(8, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East wall with door loc = Location(self, Vector3D(11, 0, 1.5)) loc.bbox = Vector3D(0.5, 5, -2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(11, 0, -2.5)) loc.bbox = Vector3D(0.5, 5, -4) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(9, 0, -6.5)) loc.bbox = Vector3D(4, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(9, 0, -6.5)) loc.bbox = Vector3D(0.5, 5, -16) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(-4, 3, 0)) loc.bbox = Vector3D(14, 0.2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # West wall loc = Location(self, Vector3D(-4, 3, 0)) loc.bbox = Vector3D(0.2, 4, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # North wall loc = Location(self, Vector3D(-4, 6.8, 0)) loc.bbox = Vector3D(14, 0.2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # East wall loc = Location(self, Vector3D(9.8, -3, 0)) loc.bbox = Vector3D(0.2, 10, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # West annex wall loc = Location(self, Vector3D(4, -3, 0)) loc.bbox = Vector3D(0.2, 6, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # South annex wall loc = Location(self, Vector3D(4, -3, 0)) loc.bbox = Vector3D(6, 0.2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(-0.5, 0, 0.5)) loc.bbox = Vector3D(8, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # West wall with door loc = Location(self, Vector3D(-0.5, 0, 0.5)) loc.bbox = Vector3D(0.2, 5, -2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(-0.5, 0, -3.5)) loc.bbox = Vector3D(0.2, 5, -12) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North wall with door loc = Location(self, Vector3D(-0.5, 0, -15.3)) loc.bbox = Vector3D(4, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(3.5, 0, -15.3)) loc.bbox = Vector3D(12, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East wall loc = Location(self, Vector3D(15.3, 0, -7.5)) loc.bbox = Vector3D(0.2, 5, -8) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # Interior wall loc = Location(self, Vector3D(7.3, 0, 0.5)) loc.bbox = Vector3D(0.2, 5, -14) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # Interior wall with door loc = Location(self, Vector3D(7.3, 0, -7.5)) loc.bbox = Vector3D(4.2, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(11.5, 0, -7.5)) loc.bbox = Vector3D(4, 5, -0.2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # South fences loc = Location(self, Vector3D(7.5, 0, 0.5)) loc.bbox = Vector3D(2, 5, -0.1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(11.5, 0, 0.5)) loc.bbox = Vector3D(4, 5, -0.1) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East fences loc = Location(self, Vector3D(15.4, 0, 0.5)) loc.bbox = Vector3D(0.1, 5, -3) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(15.4, 0, -4.5)) loc.bbox = Vector3D(0.1, 5, -3) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) return ret
def setup_operation(self, op): ret = Oplist() # South wall loc = Location(self, Vector3D(0.5, 0, 0.5)) loc.bbox = Vector3D(8, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # West wall with door loc = Location(self, Vector3D(0.5, 0, 0.5)) loc.bbox = Vector3D(0.5, 5, -2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(0.5, 0, -3.5)) loc.bbox = Vector3D(0.5, 5, -4) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North wall loc = Location(self, Vector3D(0.5, 0, -7)) loc.bbox = Vector3D(8, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North outer wall loc = Location(self, Vector3D(2.5, 0, -11)) loc.bbox = Vector3D(6, 5, -0.5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East wall with door loc = Location(self, Vector3D(8, 0, 0.5)) loc.bbox = Vector3D(0.5, 5, -2) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(8, 0, -3.5)) loc.bbox = Vector3D(0.5, 5, -8) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) return ret
vec.append(Vector3D(5, 2.7)) vec.append(Vector3D(3.2, 3)) vec.append(Vector3D(4.2, 4)) vec.append(Vector3D(5.2, 5.1)) vec.append(Vector3D(3.1, 5.2)) vec.append(Vector3D(1, 5)) vec.append(Vector3D(3, 8.2)) vec.append(Vector3D(1, 7)) """ start = [True] for i in vec: i.setY(i.getY() + 40) i.setX(i.getX() + 0) fac = Vector3D(15, 15) ly = [0] mousePos = Vector3D(-1, -1) canvas.focus_set() fortune = Fortune(vec, True) #full(None) canvas.bind("<Key>", clavier) canvas.bind("<Button-1>", mouse) canvas.pack() fenetre.mainloop()
def setup_operation(self, op): ret = Oplist() # South wall with door loc = Location(self, Vector3D(1.5, -0.5, 0)) loc.bbox = Vector3D(4, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(7.5, -0.5, 0)) loc.bbox = Vector3D(2, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # West wall loc = Location(self, Vector3D(-0.5, -0.5, 0)) loc.bbox = Vector3D(0.5, 10, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # North wall with door loc = Location(self, Vector3D(-0.5, 9, 0)) loc.bbox = Vector3D(2, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(3.5, 9, 0)) loc.bbox = Vector3D(6, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # East wall loc = Location(self, Vector3D(9, -0.5, 0)) loc.bbox = Vector3D(0.5, 10, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) # Internal walls loc = Location(self, Vector3D(3.5, -0.5, 0)) loc.bbox = Vector3D(0.5, 4.5, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) loc = Location(self, Vector3D(-0.5, 3.5, 0)) loc.bbox = Vector3D(4.5, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parent='wall', location=loc), to=self)) return ret
def __init__(self, x, y, z): Vector3D.__init__(self, x, y, z) self._tipo = randint(1, 2)
def setup_operation(self, op): ret = Oplist() # South wall with door loc = Location(self, Vector3D(-1, 1, 0)) loc.bbox = Vector3D(6, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(9, 1, 0)) loc.bbox = Vector3D(4, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # West wall with door loc = Location(self, Vector3D(-1, 1, 0)) loc.bbox = Vector3D(0.5, 2, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(-1, 7, 0)) loc.bbox = Vector3D(0.5, 4, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # North facing section loc = Location(self, Vector3D(-1, 10.5, 0)) loc.bbox = Vector3D(6, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # Remaining west facing section loc = Location(self, Vector3D(5, 7, 0)) loc.bbox = Vector3D(0.5, 10, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # North wall loc = Location(self, Vector3D(5, 16.5, 0)) loc.bbox = Vector3D(8, 0.5, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) # East wall with door loc = Location(self, Vector3D(12.5, 1, 0)) loc.bbox = Vector3D(0.5, 4, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) loc = Location(self, Vector3D(12.5, 7, 0)) loc.bbox = Vector3D(0.5, 10, 5) ret.append( Operation("create", Entity(name='wall', parents=['wall'], location=loc), to=self)) return ret
def __init__(self, position=Vector3D(0, 0, 0), color=Color(1, 1, 1, 0)): self.position = position self.color = color
def setPos(self, x, y, z): self._Pos = Vector3D(x, y, z)
def test_rot_matrices(self): m = Matrix3D.get_rot_x_matrix(100) assert m.dot(Matrix3D.identity()) == m m = Matrix3D.get_rot_y_matrix(100) assert m.dot(Matrix3D.identity()) == m m = Matrix3D.get_rot_z_matrix(100) assert m.dot(Matrix3D.identity()) == m # rotate vector only in x-axis around x - nothing should happen v1 = Vector3D(1, 0, 0, 1) assert Matrix3D.get_rot_x_matrix(100).v_dot(v1) == v1 v1 = Vector3D(0, 1, 0, 1) assert Matrix3D.get_rot_y_matrix(100).v_dot(v1) == v1 v1 = Vector3D(0, 0, 1, 1) assert Matrix3D.get_rot_z_matrix(100).v_dot(v1) == v1 # rotate vectors really v1 = Vector3D(1.0, 0.0, 0.0, 1.0) # 90 degrees or pi/2 real_v = Matrix3D.get_rot_z_matrix(math.pi / 2).v_dot(v1) test_v = Vector3D.from_list([0.000000, 1.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # 180 degrees real_v = Matrix3D.get_rot_z_matrix(math.pi).v_dot(v1) test_v = Vector3D.from_list([-1.000000, 0.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # 270 degrees real_v = Matrix3D.get_rot_z_matrix(math.pi + math.pi / 2).v_dot(v1) test_v = Vector3D.from_list([0.000000, -1.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # 360 degrees real_v = Matrix3D.get_rot_z_matrix(2 * math.pi).v_dot(v1) test_v = Vector3D.from_list([1.000000, 0.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # rotate around Y-Axis about 180 degrees real_v = Matrix3D.get_rot_y_matrix(math.pi).v_dot(v1) test_v = Vector3D.from_list([-1.000000, 0.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # rotate y:90 and x:90 -> (0, 1, 0, 1) real_v = Matrix3D.get_rot_y_matrix(math.pi / 2).v_dot(v1) test_v = Vector3D.from_list([0.000000, 0.000000, -1.000000, 1.000000]) assert real_v.nearly_equal(test_v) real_v = Matrix3D.get_rot_x_matrix(math.pi / 2).v_dot(real_v) test_v = Vector3D.from_list([0.000000, 1.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v) # and this is the combined version rot_y = Matrix3D.get_rot_y_matrix(math.pi / 2) print "rotation around y:\n", rot_y rot_x = Matrix3D.get_rot_x_matrix(math.pi / 2) print "rotation around x:\n", rot_x rot_z = Matrix3D.get_rot_z_matrix(math.pi / 2) print "rotation around z:\n", rot_z rot_m = rot_x.dot(rot_y.dot(rot_z)) print "combined rotation matrix:\n", rot_m real_v = rot_m.v_dot(v1) print "resulting vector:", real_v test_v = Vector3D.from_list([0.000000, 1.000000, 0.000000, 1.000000]) assert real_v.nearly_equal(test_v)
def __init__(self, origin=Vector3D(0, 0, 0), direction=Vector3D(1, 0, 0)): self.origin = origin self.direction = direction