Beispiel #1
0
    def set_graphicals(self):
        draw_back_x = g.scale(self.pos_x)
        draw_back_y = g.scale(self.pos_y)
        draw_front_x = g.scale(self.pos_x + self.length * cos(self.theta))
        draw_front_y = g.scale(self.pos_y + self.length * sin(self.theta))

        if self.body_back is not None and self.get_trace is False:
            self.body_back.undraw()
        self.body_back = Circle(Point(draw_back_x, draw_back_y),
                                self.body_back_radius)
        self.body_back.setFill('yellow')
        self.body_back.draw(self.win)
        if self.body_front is not None and self.get_trace is False:
            self.body_front.undraw()
        self.body_front = Circle(Point(draw_front_x, draw_front_y),
                                 self.body_front_radius)
        self.body_front.setFill('yellow')
        self.body_front.draw(self.win)
        if self.turning_arrow is not None:
            self.turning_arrow.undraw()
        self.turning_arrow = Line(
            Point(draw_front_x, draw_front_y),
            Point(draw_front_x + 20 * cos(self.theta + self.phi),
                  draw_front_y + 20 * sin(self.theta + self.phi)))
        self.turning_arrow.setFill('green')
        self.turning_arrow.setArrow('last')
        self.turning_arrow.draw(self.win)

        # Sling path related plotting
        if self.circle is not None:
            dubinc = Circle(self.circle.c.get_scaled_point(),
                            scale_vectors(self.circle.r))
            dubinc.setOutline('Green')
            dubinc.draw(self.win)
Beispiel #2
0
 def set_graphicals(self):
     # draw player
     self.body = Circle(Point(scale(self.pos_x), scale(self.pos_y)), 7)
     self.body.setFill('red')
     # Note: downwards in Y is the positive direction for this graphics lib
     #self.arrow = Line(Point(scale(self.pos_x), scale(self.pos_y)),
     #    Point(scale(self.pos_x + self.vel_x), scale(self.pos_y + self.vel_y)))
     #self.arrow.setFill('black')
     #self.arrow.setArrow('last')
     self.body.draw(self.win)
 def set_graphicals(self):
     draw_x = g.scale(self.pos_x)
     draw_y = g.scale(self.pos_y)
     if self.body is not None:
         self.body.undraw()
     self.body = Circle(Point(draw_x, draw_y), self.body_radius)
     self.body.setFill('yellow')
     self.body.draw(self.win)
     if self.arrow is not None:
         self.arrow.undraw()
     self.arrow = Line(
         Point(draw_x, draw_y),
         Point(g.scale(self.pos_x + self.vel_x),
               g.scale(self.pos_y + self.vel_y)))
     self.arrow.setFill('black')
     self.arrow.setArrow("last")
     self.arrow.draw(self.win)
Beispiel #4
0
    def set_graphicals(self):
        draw_x = scale(self.pos_x)
        draw_y = scale(self.pos_y)

        if self.circle is not None and self.get_trace is False:
            dubinc = Circle(self.circle.c.get_scaled_point(),
                            scale_vectors(self.circle.r))
            dubinc.setOutline('Green')
            dubinc.draw(self.win)

        if self.body is not None and self.get_trace is False:
            self.body.undraw()
        self.body = Circle(Point(draw_x, draw_y), self.body_radius)
        self.body.setFill('yellow')
        self.body.draw(self.win)
        if self.vel_arrow:
            self.vel_arrow.undraw()
        self.vel_arrow = Line(
            Point(draw_x, draw_y),
            Point(scale(self.pos_x + self.current_vel[0]),
                  scale(self.pos_y + self.current_vel[1])))
        self.vel_arrow.setFill('black')
        self.vel_arrow.setArrow("last")
        self.vel_arrow.draw(self.win)
        if self.acc_arrow:
            self.acc_arrow.undraw()
        self.acc_arrow = Line(
            Point(draw_x, draw_y),
            Point(scale(self.pos_x + self.current_acc[0] * 5),
                  scale(self.pos_y + self.current_acc[1] * 5)))
        self.acc_arrow.setFill('blue')
        self.acc_arrow.setArrow('last')
        self.acc_arrow.draw(self.win)
Beispiel #5
0
    def set_graphicals(self):
        draw_x = g.scale(self.pos_x)
        draw_y = g.scale(self.pos_y)
        for el in [self.body, self.velocity_arrow, self.direction_arrow, self.needed_direction_arrow]:
           if el is not None:
               el.undraw() 
        
        self.body = Circle(Point(draw_x, draw_y), self.body_radius)
        self.body.setFill('yellow')
        self.body.draw(self.win)

        if self.vel_x != 0 and self.vel_y != 0:
            self.velocity_arrow = Line(
                Point(draw_x, draw_y),
                Point(g.scale(self.pos_x +self.vel_x), g.scale(self.pos_y + self.vel_y)))
            self.velocity_arrow.setFill('black')
            self.velocity_arrow.setArrow("last")
            self.velocity_arrow.draw(self.win)

        self.direction_arrow = Line(
            Point(draw_x, draw_y),
            Point(g.scale(self.pos_x+cos(self.beta)), g.scale(self.pos_y+sin(self.beta))))
        self.direction_arrow.setFill('green')
        self.direction_arrow.setArrow("last")
        self.direction_arrow.draw(self.win)
Beispiel #6
0
    def set_graphicals(self):
        draw_x = scale(self.pos_x)
        draw_y = scale(self.pos_y)

        # Draw the new path
        if self.sling_path_calculated is not None:
            for action in self.sling_path_calculated:
                cir = Circle(action[0].get_scaled_point(), self.body_radius)
                cir.setFill('yellow')
                cir.draw(self.win)

        if self.circle is not None:
            dubinc = Circle(self.circle.c.get_scaled_point(),
                            scale_vectors(self.circle.r))
            dubinc.setOutline('Green')
            dubinc.draw(self.win)

        if self.body:
            self.body.undraw()
        self.body = Circle(Point(draw_x, draw_y), self.body_radius)
        self.body.setFill('yellow')
        self.body.draw(self.win)
        if self.vel_arrow:
            self.vel_arrow.undraw()
        self.vel_arrow = Line(
            Point(draw_x, draw_y),
            Point(scale(self.pos_x + self.current_vel[0] * 5),
                  scale(self.pos_y + self.current_vel[1] * 5)))
        self.vel_arrow.setFill('black')
        self.vel_arrow.setArrow("last")
        self.vel_arrow.draw(self.win)
        if self.acc_arrow:
            self.acc_arrow.undraw()
        self.acc_arrow = Line(
            Point(draw_x, draw_y),
            Point(scale(self.pos_x + self.current_acc[0] * 5),
                  scale(self.pos_y + self.current_acc[1] * 5)))
        self.acc_arrow.setFill('blue')
        self.acc_arrow.setArrow('last')
        self.acc_arrow.draw(self.win)
        '''