def __draw_next_target(self, drone_coo, target): stddraw.setPenRadius(0.0055) stddraw.setPenColor(c=stddraw.BLUE) stddraw.point(target[0], target[1]) stddraw.setPenColor() self.__reset_pen() stddraw.setPenColor(c=stddraw.BLUE) stddraw.setPenRadius(0.0025) stddraw.line(drone_coo[0], drone_coo[1], target[0], target[1]) self.__reset_pen()
def draw_obstacles(self): """ Spawns random obstacle segments in the map. """ stddraw.setPenColor(c=stddraw.RED) stddraw.setPenRadius(0.002) for i in range(self.simulator.n_obstacles): # generation is done only at the beginning startx, starty, endx, endy = self.simulator.environment.obstacles[ i] stddraw.line(startx, starty, endx, endy) self.__reset_pen()
def __borders_plot(self): stddraw.setPenColor(c=stddraw.RED) stddraw.setPenRadius(0.0025) stddraw.line(0, 0, 0, self.width) stddraw.line(0, 0, self.height, 0) stddraw.line(0, self.width, self.height, self.width) stddraw.line(self.height, 0, self.height, self.width) self.__reset_pen()
def grid_plot(self): """ Plots the tassellation of the area.""" if not self.simulator.grid_cell_size > 0: return # stddraw.setPenColor(c=stddraw.RED) # stddraw.setPenRadius(0.0025) stddraw.setPenColor(c=stddraw.VERY_LIGHT_GRAY) stddraw.setPenRadius(0.002) for i in range(self.simulator.grid_cell_size, self.width, self.simulator.grid_cell_size): stddraw.line(i, 0, i, self.height) for j in range(self.simulator.grid_cell_size, self.height, self.simulator.grid_cell_size): stddraw.line(0, j, self.width, j) self.__reset_pen()
def __grid_plot(self): for i in range(0, self.width, self.simulator.prob_size_cell): stddraw.setPenColor(c=stddraw.GRAY) stddraw.setPenRadius(0.0025) # x1, y1, x2, y2 stddraw.line(i, 0, i, self.height) self.__reset_pen() for j in range(0, self.height, self.simulator.prob_size_cell): stddraw.setPenColor(c=stddraw.GRAY) stddraw.setPenRadius(0.0025) # x1, y1, x2, y2 stddraw.line(0, j, self.width, j) self.__reset_pen() for cell, cell_center in utilities.TraversedCells.all_centers( self.width, self.height, self.simulator.prob_size_cell): index_cell = int(cell[0]) pr = self.simulator.cell_prob_map[index_cell][2] stddraw.text(cell_center[0], cell_center[1], "pr-c: " + str(round(pr, 4)))
def __channel_to_depot(self): stddraw.setPenColor(c=stddraw.LIGHT_GRAY) stddraw.setPenRadius(0.0025) #x1, y1, x2, y2 stddraw.line(self.width / 2, self.height, self.width / 2, 0) self.__reset_pen()
def draw_vector(self, pos, vector): stddraw.setPenRadius(0.0500) stddraw.line(pos[0], pos[1], vector[0], vector[1])