Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plot
- from mpl_toolkits.mplot3d import Axes3D
- import numpy as np
- from matplotlib.animation import FuncAnimation
- LiczbaLinii = []
- Ax = []
- Ay = []
- Az = []
- with open("wynik.txt", "r") as dane:
- wiersze = dane.readlines() # przykladowa linijka: 12,-4.3483453,1.213123,12342.123123
- for wiersz in wiersze: # rozdzelenie tekstu do poszczegolnych list
- lista = wiersz.split(',')
- LiczbaLinii.append(lista[0])
- Ax.append(lista[1])
- Ay.append(lista[2])
- lista[3] = lista[3].strip("\n")
- Az.append((lista[3]))
- def danedowykresu(num): # metoda utworzona bo szlag by trafił inaczej moje animacje
- wektor_x = Ax[num]
- wektor_y = Ay[num]
- wektor_z = Az[num]
- ax.cla() # Wyczyszczenie poprzedniego wykresu
- ax.quiver(0, 0, 0, wektor_x, 0, 0, color="green")
- ax.quiver(0, 0, 0, 0, wektor_y, 0, color="pink")
- ax.quiver(0, 0, 0, 0, 0, wektor_z, color="purple")
- ax.quiver(0, 0, 0, wektor_x, wektor_y, wektor_z) # polozenie koncowych punkow wektora, wektor a wypadk.
- ax.set_xlim(-12, 12) # zakresy na osi X
- ax.set_ylim(-12, 12)
- ax.set_zlim(-12, 12)
- ax.set_xlabel('Wartość skladowej X [m/s^2]')
- ax.set_ylabel('Wartość skladowej Y [m/s^2]')
- ax.set_zlabel('Wartość skladowej Z [m/s^2]')
- figura = plot.figure() # musi byc poza bo inaczej animacja nie dziala
- ax = figura.add_subplot(111, projection='3d')
- Animacja = FuncAnimation(figura, danedowykresu, len(LiczbaLinii)) # Animacja poklatkowa pokazujaca wektory
- plot.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement