Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import matplotlib.pyplot as plt
- import matplotlib.animation as animation
- import numpy as np
- from matplotlib.widgets import Slider, Button, RadioButtons
- from matplotlib import style
- style.use('seaborn-poster')
- def _update_plot(i, fig, scat, l,l2):
- M = ((math.sin(math.radians(i))*7.5)-(math.sin(math.radians(i/2))*9))/((math.cos(math.radians(i))*7.5)-(math.cos(math.radians(i/2))*9))
- g = M*(15-(math.cos(math.radians(i/2))*9))+(math.sin(math.radians(i/2))*9)
- scat.set_offsets(([math.cos(math.radians(i))*7.5, math.sin(math.radians(i))*7.5], [math.cos(math.radians(i/2))*9, math.sin(math.radians(i/2))*9], [0, 0]))
- if (i>=540) or (i<=180):
- l.set_data(([math.cos(math.radians(i))*7.5,math.cos(math.radians(i/2))*9],[math.sin(math.radians(i))*7.5,math.sin(math.radians(i/2))*9]))
- l2.set_data(([math.cos(math.radians(i/2))*9,15],[math.sin(math.radians(i/2))*9,g]))
- else:
- l.set_data(([0,0],[0,0]))
- l2.set_data(([0,0],[0,0]))
- return [scat,l,l2]
- fig = plt.figure()
- x = [0]
- y = [0]
- ax = fig.add_subplot(111)
- ax.set_aspect('equal')
- ax.grid(True, linestyle = '-', color = '0.10')
- ax.set_xlim([-15, 15])
- ax.set_ylim([-15, 15])
- l, = plt.plot([],[], '-', zorder=1)
- l2, = plt.plot([],[], '-', zorder=2)
- scat = plt.scatter(x, y, c = x, zorder=3)
- scat.set_alpha(0.8)
- anim = animation.FuncAnimation(fig, _update_plot, fargs = (fig, scat, l,l2),
- frames = 720, interval = 10)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement