def make_decision(params): x = int(params['x'][0]) y = int(params['y'][0]) figure_name = params['figure'][0] glass_str = params['glass'][0] print "x:", x, " y:", y, "figure:", figure_name figure = Figures[figure_name] glass = Glass(glass_str) glassWithFigure = glass.addFigure(figure, x, y) glassWithFigure.printGlass() print "Current surface range:", glass.getSurfaceRange() print "Current overal range:", glass.getGlassRange() solution = glass.findSolution(figure, x, y) print "Solution surface range:", solution[2].getSurfaceRange() print "Solution complete lines:", solution[2].getNumberOfCompleteLines() print "Solution number of holes:", solution[2].getNumberOfHoles() print "Solution max height:", solution[2].getMaxHeight() print "Solution overal range:", solution[2].getGlassRange() figure.printFigure() solutionPhrase = ("left=" + str(x - solution[0]) if (solution[0] <= x) else ("right=" + str(solution[0] - x))) solutionPhrase += ", rotate=" + str(solution[1]) solutionPhrase += ", drop" print "Solution phrase:", solutionPhrase return solutionPhrase
def __init__(self, glasstype, apex_deg, n_air=1.0): #self._apex_deg = apex_deg #self._apex_rad = np.radians(apex_deg) self._material = Glass(glasstype) self.set_apex_deg(apex_deg) self.set_n_air(n_air) # index of refraction of air in spectrograph return
def getGlass(id): id = int(id) g = None if id not in glasses: g = Glass(f.num_chunks) glasses[id] = g return glasses[id]
def init(self): """ Initialize curses. """ # Initialize ncurses library. self.stdscr = curses.initscr() curses.noecho() curses.cbreak() self.stdscr.keypad(1) curses.curs_set(0) self.width = 28 self.height = 24 # Status message. Eg. "Paused" self.status = None self.level = 1 self.score = 0 self.lines = 0 # Draw main window. self.window = curses.newwin(self.height, self.width, 0, 0) self.window.border() self.window.refresh() self.window.nodelay(1) self.glass = Glass(self) self.next_figure = None
class IsosPrismPolyhedron(PolyhedralOptic): def __init__(self, apex_angle_deg, apex_edge_mm, height_mm, glass_type, n_air=1.0, unit='mm', debug=False): super(IsosPrismPolyhedron, self).__init__() self._unit = unit self._debug = debug self._apex_rad = np.radians(apex_angle_deg) self._height_mm = height_mm self._ap_edge_mm = apex_edge_mm self._symaxis_mm = 0.5 * self._ap_edge_mm / np.tan(self._apex_rad / 2.) self._vtx = {} self._vtx['bot'] = self._bottom_vertices() self._vtx['top'] = self._vtx['bot'] \ + np.array([0.0, 0.0, self._height_mm]) self._vtx['all'] = np.vstack((self._vtx['bot'], self._vtx['top'])) #self.barycenter = self.get_center() self.recenter_origin() self._faces['top'] = self._make_face(self._vtx['top']) # FIXME: self._faces['bot'] = self._make_face(self._vtx['bot'][::-1, :]) #self._faces['bot'] = self._make_face(self._vtx['bot']) self._faces['face1'] = self._prism_face((0, 1)) self._faces['face2'] = self._prism_face((1, 2)) self._faces['face3'] = self._prism_face((2, 0)) #j = calc_surface_vectors(traj0, prf1['normal'], p_n1n2)[1] self._update_face_names() #self._update_face_normals() self._update_face_names_norms() # Indexes of refraction: self._n_air = n_air self._glass = Glass(glass_type) return def _bottom_vertices(self): vtx1 = np.array([0.5 * self._ap_edge_mm, 0.0, 0.0]) vtx2 = np.array([0.0, self._symaxis_mm, 0.0]) vtx3 = np.array([-0.5 * self._ap_edge_mm, 0.0, 0.0]) return np.array([vtx1, vtx2, vtx3]) #def _prism_face(self, bvlist): # tmpvtx = [self._vtx['bot'][x] for x in bvlist] # bottom vertices # tmpvtx += [self._vtx['top'][x] for x in reversed(bvlist)] # add tops # return self._make_face(np.array(tmpvtx)) def _n1n2_ratio(self, wl_um): return self._n_air / self._glass.refraction_index(wl_um)
def __init__(self, apex_angle_deg, apex_edge_mm, height_mm, glass_type, n_air=1.0, unit='mm', debug=False): super(IsosPrismPolyhedron, self).__init__() self._unit = unit self._debug = debug self._apex_rad = np.radians(apex_angle_deg) self._height_mm = height_mm self._ap_edge_mm = apex_edge_mm self._symaxis_mm = 0.5 * self._ap_edge_mm / np.tan(self._apex_rad / 2.) self._vtx = {} self._vtx['bot'] = self._bottom_vertices() self._vtx['top'] = self._vtx['bot'] \ + np.array([0.0, 0.0, self._height_mm]) self._vtx['all'] = np.vstack((self._vtx['bot'], self._vtx['top'])) #self.barycenter = self.get_center() self.recenter_origin() self._faces['top'] = self._make_face(self._vtx['top']) # FIXME: self._faces['bot'] = self._make_face(self._vtx['bot'][::-1, :]) #self._faces['bot'] = self._make_face(self._vtx['bot']) self._faces['face1'] = self._prism_face((0, 1)) self._faces['face2'] = self._prism_face((1, 2)) self._faces['face3'] = self._prism_face((2, 0)) #j = calc_surface_vectors(traj0, prf1['normal'], p_n1n2)[1] self._update_face_names() #self._update_face_normals() self._update_face_names_norms() # Indexes of refraction: self._n_air = n_air self._glass = Glass(glass_type) return
def __init__(self, numberOfRows): GLASS_CAPACITY = 0.25 if numberOfRows <= 0: raise ValueError( "Number of rows must be greater than zero. Given number of rows: {0}" .format(numberOfRows)) if not isinstance(numberOfRows, int): raise ValueError( "Number of rows must be an integer. Given number of rows: {0}". format(numberOfRows)) self.stack = [] for row in range(numberOfRows): numberOfColumns = row + 1 self.stack.append([Glass(GLASS_CAPACITY)] * numberOfColumns)
def main(): args = read_args() if args.debug_barcodes: valid_barcodes = load_barcodes(args) truth = None if args.truth is not None: truth, file_size = read_file(args.truth, args.size) g = Glass(args.chunk_num, header_size=args.header_size, rs=args.rs, c_dist=args.c_dist, delta=args.delta, flag_correct=not (args.no_correction), gc=args.gc, max_homopolymer=args.max_homopolymer, max_hamming=args.max_hamming, decode=not (args.mock), exDNA=args.expand_nt, chunk_size=args.size, np=args.rand_numpy, truth=truth, out=args.out) line = 0 errors = 0 seen_seeds = defaultdict(int) #pbar = tqdm(total= args.chunk_num, desc = "Valid oligos") if args.file_in == '-': f = sys.stdin else: try: f = open(args.file_in, 'r') except: logging.error("%s file not found", args.text_file) sys.exit(0) aggressive = None if args.aggressive: aggressive = Aggressive(g=g, file_in=f, times=args.aggressive) ######## Main loop while True: try: dna = f.readline().rstrip('\n') except: logging.info("Finished reading input file!") break if len(dna) == 0: logging.info("Finished reading input file!") break if (args.fasta and re.search(r"^>", dna)): continue coverage = 0 #when the file is in the format of coverage \t DNA if (len(dna.split()) == 2): coverage, dna = dna.split() ####Aggresive mode if aggressive is not None and aggressive.turn_on( int(coverage), seen_seeds): best_file, value = aggressive.start() if best_file is not None: copyfile(best_file, args.out) logging.info("Done!") else: logging.error("Could not decode all file...") sys.exit(1) ### End of aggressive mode if 'N' in dna: continue line += 1 seed, data = g.add_dna(dna) if seed == -1: #reed-solomon error! errors += 1 else: #pbar.update() if args.debug_barcodes: if not dna in valid_barcodes: logging.error( "Seed or data %d in line %d are not valid:%s", seed, line, dna) else: seen_seeds[dna] += 1 else: seen_seeds[seed] += 1 if line % 1000 == 0: logging.info( "After reading %d lines, %d chunks are done. So far: %d rejections (%f) %d barcodes", line, g.chunksDone(), errors, errors / (line + 0.0), g.len_seen_seed()) pass if line == args.max_line: logging.info("Finished reading maximal number of lines") break if g.isDone(): logging.info( "After reading %d lines, %d chunks are done. So far: %d rejections (%f) %d barcodes", line, g.chunksDone(), errors, errors / (line + 0.0), g.len_seen_seed()) logging.info("Done!") break if not g.isDone(): logging.error("Could not decode all file...") sys.exit(1) outstring = g.getString() f = open(args.out, 'wb') f.write(outstring) f.close() logging.info("MD5 is %s", md5.new(outstring).hexdigest()) json.dump(seen_seeds, open("seen_barocdes.json", 'w'), sort_keys=True, indent=4)
def main(): args = read_args() if args.debug_barcodes: valid_barcodes = load_barcodes(args) comp = None if args.composite_DNA is not None: # alphabet is a dict of int->letter including the std 0->A,1->C,2->G,3->T # the composite alphabet file only contains an ordered list of the *additional* letters alphabet = read_composite_alphabet(args.composite_DNA[0]) BC_bases = int(args.composite_DNA[1]) # TODO - set max binary block limit somehow, get oligo length from somewhere if args.composite_encoder is not None: composite_encoder = create_composite_encoder( alphabet, int(args.composite_encoder[0]), int(args.composite_encoder[1])) else: composite_encoder = create_optimal_composite_encoder( alphabet, 10, 136) comp = { 'alphabet': alphabet, 'BC_bases': BC_bases, 'encoder': composite_encoder } truth = None if args.truth is not None: truth, file_size = read_file(args.truth, args.size) g = Glass(args.chunk_num, header_size=args.header_size, rs=args.rs, c_dist=args.c_dist, delta=args.delta, flag_correct=not (args.no_correction), gc=args.gc, max_homopolymer=args.max_homopolymer, max_hamming=args.max_hamming, decode=not (args.mock), chunk_size=args.size, np=args.rand_numpy, truth=truth, out=args.out, comp=comp) line = 0 errors = 0 seen_seeds = defaultdict(int) # pbar = tqdm(total= args.chunk_num, desc = "Valid oligos") if args.file_in == '-': f = sys.stdin else: try: f = open(args.file_in, 'r') except: logging.error("%s file not found", args.text_file) sys.exit(0) aggressive = None if args.aggressive: aggressive = Aggressive(g=g, file_in=f, times=args.aggressive) ######## Main loop while True: try: dna = f.readline().rstrip('\n') except: logging.info("Finished reading input file!") break if len(dna) == 0: logging.info("Finished reading input file!") break if (args.fasta and re.search(r"^>", dna)): continue coverage = 0 # when the file is in the format of coverage \t DNA if (len(dna.split()) == 2): coverage, dna = dna.split() ####Aggresive mode if aggressive is not None and aggressive.turn_on( int(coverage), seen_seeds): best_file, value = aggressive.start() if best_file is not None: copyfile(best_file, args.out) logging.info("Done!") else: logging.error("Could not decode all file...") sys.exit(1) ### End of aggressive mode if 'N' in dna and comp is None: continue line += 1 seed, data = g.add_dna(dna) if seed == -1: # reed-solomon error! errors += 1 else: # pbar.update() if args.debug_barcodes: if not dna in valid_barcodes: logging.error( "Seed or data %d in line %d are not valid:%s", seed, line, dna) else: seen_seeds[dna] += 1 else: seen_seeds[seed] += 1 if line % 10000 == 0: logging.info( "After reading %d lines, %d chunks are done. So far: %d rejections (%f) %d barcodes", line, g.chunksDone(), errors, errors / (line + 0.0), g.len_seen_seed()) pass if line == args.max_line: logging.info("Finished reading maximal number of lines") break if g.isDone(): logging.info( "After reading %d lines, %d chunks are done. So far: %d rejections (%f) %d barcodes", line, g.chunksDone(), errors, errors / (line + 0.0), g.len_seen_seed()) logging.info("Done!") break if not g.isDone(): logging.error("Could not decode all file...") sys.exit(1) outstring = g.getString() f = open(args.out, 'wb') f.write(outstring) f.close() logging.info("MD5 is %s", md5.new(outstring).hexdigest()) json.dump(seen_seeds, open("seen_barocdes.json", 'w'), sort_keys=True, indent=4)
class Screen: """ Represents drawable part of the terminal, where other parts (glass, figures) are drawed. """ glass = None def init(self): """ Initialize curses. """ # Initialize ncurses library. self.stdscr = curses.initscr() curses.noecho() curses.cbreak() self.stdscr.keypad(1) curses.curs_set(0) self.width = 28 self.height = 24 # Status message. Eg. "Paused" self.status = None self.level = 1 self.score = 0 self.lines = 0 # Draw main window. self.window = curses.newwin(self.height, self.width, 0, 0) self.window.border() self.window.refresh() self.window.nodelay(1) self.glass = Glass(self) self.next_figure = None def destroy(self): """ Free ncurses library resources and back screen to normal mode. """ # Release ncurses. curses.nocbreak() self.stdscr.keypad(0) curses.echo() curses.endwin() curses.curs_set(1) def move_figure_to_start(self, figure): """ Move figure to start position. Figure shoud appears at the middle top of the glass. """ figure.y = 0 figure.x = math.floor(self.glass.width / 2) def draw(self, figure): """ Redraw the screen. """ y_base = 10 x_base = self.glass.width + 4 self.window.move(y_base, x_base) self.window.addstr("Score:" + "{0:>6}".format(self.score)) self.window.move(y_base + 1, x_base) self.window.addstr("Lines:" + "{0:>6}".format(self.lines)) self.window.move(y_base + 2, x_base) self.window.addstr("Level:" + "{0:>6}".format(self.level)) self.window.move(y_base + 4, x_base) if self.status: self.window.addstr(self.status, curses.A_BLINK) else: self.window.addstr(" " * (self.width - 1 - x_base)) self.glass.clear() self.glass.draw() # # Draw next picture preview. # # Clear place before. for y in range(self.preview_figure.y - 2, self.preview_figure.y + 3): for x in range(self.preview_figure.x - 2, self.preview_figure.x + 3): self.window.move(y, x) self.window.addstr(" ") self.preview_figure.draw(self.window, self.width, self.height) figure.draw(self.glass.window, self.glass.width, self.glass.height) def set_next_figure(self, figure): """ Set next falling figure for preview. """ self.preview_figure = copy.copy(figure) self.preview_figure.x = self.glass.width + 7 self.preview_figure.y = 5 def getch(self): """ Return pressed key. """ return self.window.getch() def move_figure_down(self, figure): """ Move figure down for one position, -- falling. Returns False if figure was joined to lees. """ if self._is_figure_down_moveable(figure): figure.y += 1 return True else: # Figure should be joined to lees. self.glass.lees_figure(figure) return False def _is_figure_down_moveable(self, figure): """ Returns True if figure can be moved down. """ bottoms = figure.get_bottom_positions() for i, y in enumerate(bottoms): lees_top = self.glass.get_lees_top(figure.x - 2 + i) if y >= lees_top - 1 or y >= self.glass.height: return False return True def move_figure_right(self, figure): """ Move figure one position right. """ if self._is_figure_right_moveable(figure): figure.x += 1 def move_figure_left(self, figure): """ Move figure one position left. """ if self._is_figure_left_moveable(figure): figure.x -= 1 def _is_figure_right_moveable(self, figure): """ Returns True if this figure can be moved right at least one step. """ right_edge = figure.get_right_edge() sprite = figure.get_sprite() return right_edge < self.glass.width - 1 and self._is_space_free(figure.y, figure.x + 1, sprite) def _is_figure_left_moveable(self, figure): """ Returns True if this figure can be moved left at least one step. """ left_edge = figure.get_left_edge() sprite = figure.get_sprite() return left_edge > 0 and self._is_space_free(figure.y, figure.x - 1, sprite) def rotate_figure_anticlockwise(self, figure): """ Rotate figure contraclockwise. """ i = figure.get_prev_sprite_index() # We can't rotate if figure will be outside the glass. right_edge = figure.get_right_edge(i) left_edge = figure.get_left_edge(i) if right_edge >= self.glass.width or left_edge < 0: return # Or figure will be under the glass's floor. bottoms = figure.get_bottom_positions(i) for y in bottoms: if y >= self.glass.height: return # And we have free place for future sprite. i = figure.get_prev_sprite_index() sprite = figure.get_sprite(i) if not self._is_space_free(figure.y, figure.x, sprite): return figure.rotate_anticlockwise() def rotate_figure_clockwise(self, figure): """ Rotate figure clockwise, if it can be rotated. """ i = figure.get_next_sprite_index() # Block rotation if figure will be moved outside the glass. right_edge = figure.get_right_edge(i) left_edge = figure.get_left_edge(i) if right_edge >= self.glass.width or left_edge < 0: return # Or under the floor. bottoms = figure.get_bottom_positions(i) for y in bottoms: if y >= self.glass.height: return # And we have free place for the next sprite. i = figure.get_next_sprite_index() sprite = figure.get_sprite() if not self._is_space_free(figure.y, figure.x, sprite): return figure.rotate_clockwise() def _is_space_free(self, y, x, sprite): """ Returns True if space for the given sprite is fee (without lees) in glass. """ for yy, row in enumerate(sprite): for xx, cel in enumerate(row): if cel > 0: if not self.glass.is_space_free(y - 2 + yy, x - 2 + xx): return False return True def delete_full_lines(self): """ Remove full lines and returns their count. """ return self.glass.delete_full_lines()
class Prism(object): def __init__(self, glasstype, apex_deg, n_air=1.0): #self._apex_deg = apex_deg #self._apex_rad = np.radians(apex_deg) self._material = Glass(glasstype) self.set_apex_deg(apex_deg) self.set_n_air(n_air) # index of refraction of air in spectrograph return # ------------------------------------- # Getters and setters: def get_apex_rad(self): return self._apex_rad def get_apex_deg(self): return self._apex_deg def set_apex_deg(self, apex_deg): self._apex_deg = apex_deg self._apex_rad = np.radians(apex_deg) return def set_n_air(self, index_refr): self._n_air = index_refr return # ------------------------------------- @staticmethod def _wiki_deflection_rad_nr(i, A, nr): """Deflection angle using formula from Wikipedia (which seems to be identical to others used here. Inputs are: i -- incidence angle (RADIANS) A -- prism apex angle (RADIANS) nr -- index of refraction RATIO at desired wavelength(s): n_glass / n_air """ return i - A + np.arcsin(nr * np.sin(A - np.arcsin(np.sin(i) / nr))) def deflection_rad_nr(self, incidence_r, nr): """Deflection angle as a function of incidence angle and index of refraction RATIO (n_glass / n_air).""" return self._wiki_deflection_rad_nr(incidence_r, self._apex_rad, nr) def deflection_rad_nr2(self, incidence_r, nr2): """Calculate deflection angle from incidence and SQUARED index of refraction RATIO (glass / air). Units of RADIANS used throughout.""" ptemp = np.sqrt(nr2 - np.sin(incidence_r)**2) * np.sin(self._apex_rad) \ - np.cos(self._apex_rad) * np.sin(incidence_r) return incidence_r - self._apex_rad + np.arcsin(ptemp) def deflection_rad_wl(self, incidence_r, wavelength_um): """Calculate deflection angle given incidence angle and wavelength in microns. Units of RADIANS used throughout.""" n2_glass = self._material.refraction_index_squared(wavelength_um) n2_air = self._n_air**2 return self.deflection_rad_nr2(incidence_r, n2_glass/n2_air) #ptemp = np.sqrt(n2 - np.sin(incidence_r)**2) * np.sin(self._apex_rad) \ # - np.cos(self._apex_rad) * np.sin(incidence_r) #return incidence_r - self._apex_rad + np.arcsin(ptemp) def deflection_deg_wl(self, incidence_d, wavelength_um): """Calculate deflection angle given incidence angle and wavelength in microns. Units of RADIANS used throughout.""" incidence_r = np.radians(incidence_deg) return np.degrees(self.deflection_rad_wl(incidence_r, wavelength_um))
def main(): pygame.init() display = (1900, 1000) pygame.display.set_mode(display, DOUBLEBUF | OPENGL) u = 0 #pygame.mixer.music.load("Experience.mp3") #pygame.mixer.music.play() gluPerspective(45, (display[0] / display[1]), 0.1, 100.0) glTranslatef(0, 0, -70) object_passed = False i = 0 controllore = 0 s = 0 w = 0 camera_y = 0 rotazione = 0 while not object_passed: if rotazione == 72 or rotazione == -72: rotazione = 0 glClearColor(1, 1, 0.9, 0) if i == 1: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: glTranslatef(0.5, 0, 0) if event.key == pygame.K_RIGHT: glTranslatef(-0.5, 0, 0) if event.key == pygame.K_UP: glTranslatef(0, -1, 0) if event.key == pygame.K_DOWN: if camera_y < 1: glTranslatef(0, 1, 0) if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 4: glTranslatef(0, 0, 1.0) if event.button == 5: glTranslatef(0, 0, -1.0) keypress = pygame.key.get_pressed() if keypress[pygame.K_a]: rotazione = rotazione - 1 glRotate(5, 0, 0.5, 0) #ang,x,y,z if keypress[pygame.K_w]: if w < 35: w = w + 1 glRotate(5, 0.5, 0, 0) #ang,x,y,z if keypress[pygame.K_s]: rotazione = rotazione + 1 glRotate(5, 0, -0.5, 0) #ang,x,y,z if keypress[pygame.K_z]: if w > 0: w = w - 1 glRotate(5, -0.5, 0, 0) #ang,x,y,z x = glGetDoublev(GL_MODELVIEW_MATRIX) #, modelviewMatrix) camera_x = x[3][0] camera_y = x[3][1] camera_z = x[3][2] #print('rotazione',rotazione) # slowly move forward : if camera_z >= 40 and i == 0: glTranslatef(0, 0, 0.8) else: i = 1 controllore = 1 glTranslatef(0, 0, 0) if (rotazione < 40 and rotazione > -1) or (rotazione < -49 and rotazione > -72): glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) if controllore == 0: u = 0 Ground() if (rotazione > 21 and rotazione < 51) or (rotazione < -19 and rotazione > -52): Skeleton(u) glPushMatrix() glRotate(270, 0, 1, 0) glTranslated(-1.5, -1, 0) Chair() glPopMatrix() glPushMatrix() glRotate(120, 0, 1, 0) glTranslated(-14, -9, 9) Table() glPopMatrix() glPushMatrix() glTranslated(13, -1, 7) Dish() glPopMatrix() glPushMatrix() glTranslated(18, -1, 9) Glass() glPopMatrix() u = u + 1 if u < 371: u = u else: u = 0 else: glPushMatrix() glRotate(270, 0, 1, 0) glTranslated(-1.5, -1, 0) Chair() glPopMatrix() Skeleton(u) glPushMatrix() glRotate(120, 0, 1, 0) glTranslated(-14, -9, 9) Table() glPopMatrix() glPushMatrix() glTranslated(13, -1, 7) Dish() glPopMatrix() glPushMatrix() glTranslated(18, -1, 9) Glass() glPopMatrix() u = u + 1 if u < 371: u = u else: u = 0 else: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) if controllore == 0: u = 0 Ground() if (rotazione > 21 and rotazione < 51) or (rotazione < -19 and rotazione > -52): glPushMatrix() glRotate(120, 0, 1, 0) glTranslated(-14, -9, 9) Table() glPopMatrix() glPushMatrix() glTranslated(13, -1, 7) Dish() glPopMatrix() glPushMatrix() glTranslated(18, -1, 9) Glass() glPopMatrix() Skeleton(u) glPushMatrix() glRotate(270, 0, 1, 0) glTranslated(-1.5, -1, 0) Chair() glPopMatrix() u = u + 1 if u < 371: u = u else: u = 0 else: glPushMatrix() glRotate(270, 0, 1, 0) glTranslated(-1.5, -1, 0) Chair() glPopMatrix() glPushMatrix() glRotate(120, 0, 1, 0) glTranslated(-14, -9, 9) Table() glPopMatrix() glPushMatrix() glTranslated(13, -1, 7) Dish() glPopMatrix() glPushMatrix() glTranslated(18, -1, 9) Glass() glPopMatrix() Skeleton(u) u = u + 1 if u < 371: u = u else: u = 0 #print(u) pygame.display.flip() if camera_z <= 0: object_passed = True