diff --git a/1.py b/1.py new file mode 100644 index 000000000..9ef641fe4 --- /dev/null +++ b/1.py @@ -0,0 +1,43 @@ +# Импортируем библиотеки +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.animation import FuncAnimation + +# Создание пространства и подпространства для анимации +fig, ax = plt.subplots() + +# Объект анимации +anim_object, = plt.plot([], [], '-', lw=2) + +x, y = [], [] # Координаты объекта анимации +frames_interval = np.linspace(-5, 5, 100) + +ax.set_xlim(10,30) # Пределы изменения переменной Х +ax.set_ylim(-10,10) # Пределы изменения переменной У + + + + +def cucloid_move(r,t): + x = r*(t-np.sin(t)**3) # Расчет координаты Х + y = r*(1-np.cos(t)**3) # Расчет координаты У + + return x, y + +ball, = plt.plot([], [], 'o', color='r', label='Ball') +ball_line, = plt.plot([], [], '-', color='r', label='Ball') + +frames = 180 + +coords = np.zeros((frames, 2)) + + +def animate(i): + coords[i] = cucloid_move(r=3, t = 5) + ball.set_data([coords[i][0]], [coords[i][1]]) + ball_line.set_data(coords[:i, 0], coords[:i, 1]) + + return ball, ball_line + +ani = FuncAnimation(fig, animate, frames=frames, interval=30) +ani.save('cucold.gif', writer="pillow") \ No newline at end of file diff --git a/animation_1.gif b/animation_1.gif new file mode 100644 index 000000000..2f12bc721 Binary files /dev/null and b/animation_1.gif differ diff --git a/animation_2.gif b/animation_2.gif new file mode 100644 index 000000000..e329bfae1 Binary files /dev/null and b/animation_2.gif differ diff --git a/circle.py b/circle.py new file mode 100644 index 000000000..c19cfea4d --- /dev/null +++ b/circle.py @@ -0,0 +1,30 @@ +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.animation import FuncAnimation + +def circle_move(R,angle_vel,time): + alpha = angle_vel * np.pi / 180 * time + x = R * np.cos(alpha) + y = R * np.sin(alpha) + return x, y + +fig, ax = plt.subplots() +ball, = plt.plot([],[],'o',color='r',label='ball') +ball_line, = plt.plot([],[],'-',color='r',label='ball') + +frames = 180 +coords = np.zeros((frames,2)) + +def animate(i): + coords[i] = circle_move(R=2, angle_vel = 1, time = i) + ball.set_data([coords[i][0]],[coords[i][1]]) + ball_line.set_data(coords[:i,0],coords[:i,1]) + return ball, ball_line +edge = 10 +plt.axis('equal') +ax.set_xlim(-edge,edge) +ax.set_ylim(-edge,edge) + + +ani = FuncAnimation(fig,animate,frames=frames,interval=50) # по умолчанию 200 милисекунд +ani.save('animation_1.gif', writer="pillow") \ No newline at end of file diff --git a/cucold.gif b/cucold.gif new file mode 100644 index 000000000..ac6bc4fc3 Binary files /dev/null and b/cucold.gif differ diff --git a/fig_1.png b/fig_1.png new file mode 100644 index 000000000..78a739640 Binary files /dev/null and b/fig_1.png differ diff --git a/new_cucold.py b/new_cucold.py new file mode 100644 index 000000000..cc0b66c17 --- /dev/null +++ b/new_cucold.py @@ -0,0 +1,29 @@ +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.animation import FuncAnimation + +#пространство и подпространство для анимации +fig, ax = plt.subplots() + +#обьект анимации +anim_object, = plt.plot([],[],'-',lw =2) +x, y = [],[] #координаты +frames_interval = np.linspace(0,20, 100) + +#перделы +ax.set_xlim(0,20) +ax.set_ylim(0,8) + +def update(frame): + x.append(frame) + y.append(np.sin(frame)) + + anim_object.set_data(x,y) + + return anim_object + +ani = FuncAnimation(fig, #выз0ов фигуры + update, #вызов функции + frames=frames_interval, + interval = 50) +ani.save('animation_1.gif', writer="pillow") \ No newline at end of file diff --git a/sinus.py b/sinus.py new file mode 100644 index 000000000..c976ea229 --- /dev/null +++ b/sinus.py @@ -0,0 +1,29 @@ +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.animation import FuncAnimation + +#пространство и подпространство для анимации +fig, ax = plt.subplots() + +#обьект анимации +anim_object, = plt.plot([],[],'-',lw =2) +x, y = [],[] #координаты +frames_interval = np.linspace(0,2*np.pi, 100) + +#перделы +ax.set_xlim(0,2*np.pi) +ax.set_ylim(-1,1) + +def update(frame): + x.append(frame) + y.append(np.sin(frame)) + + anim_object.set_data(x,y) + + return anim_object + +ani = FuncAnimation(fig, #выз0ов фигуры + update, #вызов функции + frames=frames_interval, + interval = 50) +ani.save('animation_1.gif', writer="pillow") \ No newline at end of file