Skip to content
Open

pipa #91

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions 1.py
Original file line number Diff line number Diff line change
@@ -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")
Binary file added animation_1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animation_2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions circle.py
Original file line number Diff line number Diff line change
@@ -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")
Binary file added cucold.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions new_cucold.py
Original file line number Diff line number Diff line change
@@ -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")
29 changes: 29 additions & 0 deletions sinus.py
Original file line number Diff line number Diff line change
@@ -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")