forked from novikov-igor1209/final_project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (43 loc) · 1.25 KB
/
main.py
File metadata and controls
49 lines (43 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from functions import read_file, count_coords
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from config import FILENAME, SIZE_COEF
data = read_file(FILENAME)
masses = data[:, 0]
x = data[:, 1]
y = data[:, 2]
vx = data[:, 3]
vy = data[:, 4]
axprev = np.zeros_like(x)
ayprev = np.zeros_like(y)
'''
fig, ax = plt.subplots(figsize=(15, 15))
n = len(x)
points = []
points.append(ax.plot([], [], 'o', markersize=6)[0])
for _ in range(1, n):
points.append(ax.plot([], [], 'o', markersize=4)[0])
lim = SIZE_COEF * max(x)
ax.set_xlim(-lim, lim)
ax.set_ylim(-lim, lim)
ax.set_aspect('equal')
def init():
for point in points:
point.set_data([], [])
return points
def update(frame):
global x, y, vx, vy, masses, axprev, ayprev
x, y, vx, vy, axprev, ayprev = count_coords(x, y, vx, vy, masses, axprev, ayprev)
for i, point in enumerate(points):
point.set_xdata([x[i]])
point.set_ydata([y[i]])
return points
anim = FuncAnimation(fig, update, init_func=init, frames=200, interval=1, blit=True)
plt.tight_layout()
plt.show()'''
coords = []
for i in range(2000):
x, y, vx, vy, axprev, ayprev = count_coords(x, y, vx, vy, masses, axprev, ayprev)
coords.append([x, y])
print(coords)