def __init__(self, scale, x, y, vel_vector, canvas_info, mass=42 * u.kg, filename="Images/net.png"): super().__init__(filename, scale) if type(x) != type(1 * u.m): x *= u.km y *= u.km print("Projectile called without units") self.model_x = x #model is the postion in the background model self.model_y = y self.center_x, self.center_y = functions.get_canvas_pos( x, y, canvas_info) #center is the postion on canvas self.vel_vector = vel_vector if type(self.vel_vector) != type([0, 0, 0] * u.m / u.s): self.vel_vector = self.vel_vector * u.m / u.s self.angle = functions.vec_to_angle_2d(self.vel_vector[0].value, self.vel_vector[1].value) self.mass = mass
def __init__(self, x, y, vel_vector, path, canvas_info, mass=42 * u.kg, filename="Images/debris.png"): super().__init__(filename=path, scale=0.2) self.model_x = x * u.km #model is the postion in the background model self.model_y = y * u.km self.center_x, self.center_y = functions.get_canvas_pos( x, y, canvas_info) #center is the postion on canvas self.vel_vector = vel_vector self.speed = 0 self.altitude = 0 #Create an orbit object, which a debris is. r = [-6045, -3490, 2500] v = [-3457, 6618, 2533] rtest, vtest = functions.get_random_ellipse_orbit() self.orbit = Orbit.from_vectors(Earth, rtest * u.km, vtest * u.m / u.s) self.update(0.00001, [0, 0, 0, 0]) self.mass = mass
def update(self, delta_time, canvas_info, debris=None): if debris == None: self.model_x += self.vel_vector[0] * delta_time * u.s self.model_y += self.vel_vector[1] * delta_time * u.s else: self.model_x = debris.model_x self.model_y = debris.model_y self.center_x, self.center_y = functions.get_canvas_pos( self.model_x, self.model_y, canvas_info)
def update(self, delta_time, canvas_info): self.altitude = round( math.sqrt((self.model_x.value)**2 + (self.model_y.value)**2) - 6371, 3) #We move the debris a certain time. self.orbit = self.orbit.propagate(delta_time * u.s) self.model_x, self.model_y = functions.orbit_to_position(self.orbit) self.set_vel_vector() self.center_x, self.center_y = functions.get_canvas_pos( self.model_x, self.model_y, canvas_info)
def update(self, delta_time, canvas_info, total_time): self.canvas_info = canvas_info if self.rotation_start[0]: self.rotation_info = functions.rotate_satellite( self, self.rotation_start[1], total_time) self.rotation_start[0] = False if self.rotation_info[0]: self.angle, self.rotation_info = functions.update_satellite_rotation( self, total_time) #We move the debris a certain time. self.orbit = self.orbit.propagate(delta_time * u.s) self.model_x, self.model_y = functions.orbit_to_position(self.orbit) self.set_vel_vector() #Update the time to shoot: self.time_to_shoot -= delta_time * u.s self.time_to_hit -= delta_time * u.s self.center_x, self.center_y = functions.get_canvas_pos( self.model_x, self.model_y, canvas_info)
def update(self, delta_time, canvas_info): self.center_x, self.center_y = functions.get_canvas_pos( self.model_x, self.model_y, canvas_info)