def on_timer(self, *args):
     if len(self.positions) == 0 or self.index == len(self.positions[0]):
         self.pendulum.m1 = self.m1
         self.pendulum.m2 = self.m2
         self.pendulum.l1 = self.l1
         self.pendulum.l2 = self.l2        
         if self.animation:
             self.positions = double_pendulum_odeint(self.pendulum, 0, 0.5, 0.02)
         else:
             self.positions = double_pendulum_odeint(self.pendulum, 0, 0.00001, 0.00001)
         self.index = 0
     self.graph.p = tuple(array[self.index] for array in self.positions)
     self.index += 1
     self.graph.request_redraw()
 def on_timer(self, *args):
     if len(self.positions) == 0 or self.index == len(self.positions[0]):
         self.pendulum.m1 = self.m1
         self.pendulum.m2 = self.m2
         self.pendulum.l1 = self.l1
         self.pendulum.l2 = self.l2
         if self.animation:
             self.positions = double_pendulum_odeint(
                 self.pendulum, 0, 0.5, 0.02)
         else:
             self.positions = double_pendulum_odeint(
                 self.pendulum, 0, 0.00001, 0.00001)
         self.index = 0
     self.graph.p = tuple(array[self.index] for array in self.positions)
     self.index += 1
     self.graph.request_redraw()
Exemplo n.º 3
0
def update_line(event):
    global x1, x2, y1, y2, idx
    if idx == len(x1):
        x1, y1, x2, y2 = double_pendulum_odeint(pendulum, 0, 1, 0.05)
    idx = 0
    line1.set_xdata([0, x1[idx]])
    line1.set_ydata([0, y1[idx]])
    line2.set_xdata([x1[idx], x2[idx]])
    line2.set_ydata([y1[idx], y2[idx]])
    fig.canvas.draw()
    idx += 1
Exemplo n.º 4
0
def update_line(event):
    global x1, x2, y1, y2, idx
    if idx == len(x1):
        x1, y1, x2, y2 = double_pendulum_odeint(pendulum, 0, 1, 0.05)
        idx = 0
    line1.set_xdata([0, x1[idx]])
    line1.set_ydata([0, y1[idx]])
    line2.set_xdata([x1[idx], x2[idx]])
    line2.set_ydata([y1[idx], y2[idx]])
    fig.canvas.draw()
    idx += 1