def crtanje_planeta(y_max, plot=True): broj_tacaka = int(y_max*365*2) broj_planeta = 5 t = np.linspace(0, y_max*365*24*3600, broj_tacaka) x = [[] for _ in range(broj_planeta)] y = [[] for _ in range(broj_planeta)] indeksi_planeta = [1, 2, 3, 4, 5, 6, 7, 8] # indeksi planeta koje crtamo for i in range(broj_tacaka): for j in range(broj_planeta): # koliko planeta crtamo rez = simulacija_pogon.polozaj_planeta(indeksi_planeta[j], t[i], matrica=False) x[j].append(rez[0]) y[j].append(rez[1]) if plot: plt.plot(x[0], y[0], 'g', x[1], y[1], 'y', x[2], y[2], 'b', x[3], y[3], linewidth=0.8) # plt.setp(putanje,markersize=2.5) plt.plot(0.0, 0.0, 'k*', markersize=7) plt.axis('scaled') plt.title('Putanje Merkura, Venere, Zemlje i Marsa oko Sunca') plt.xlabel('x koord [astronomska jedinica]') plt.ylabel('y koord [astronomska jedinica]') plt.show() else: return x, y
from simulacija_pogon import polozaj_planeta from podaci import beg_of_time import datetime as dt import numpy as np import math f = open('polozaji_planeta.txt', 'w+b') date = dt.datetime(2019, 1, 1, 0, 0, 0) np.save('datum', [date]) years = 4 np.save('years', years) step = dt.timedelta(hours=1) np.save('step', [step]) planets_position = np.empty((math.floor(years * 365.25 * 24), 8, 2)) for i in range(planets_position.shape[0]): for j in range(8): planets_position[i][j] = polozaj_planeta( j, (date - beg_of_time).total_seconds(), matrica=False)[:2] date = date + dt.timedelta(hours=1) np.save('polozaji_planeta', planets_position)