I shall plot the earth surrounding the sun. Therefore the task is splitted into 2 subtasks. At the first task I shall approximate that the motion is one a circle.
I used following code to get the solution but somehow the programm will edit one dot instead of several. Can you pls help me with my algorithm.
So my code:
npoints = 360
x= np.zeros((npoints,1))
y= np.zeros((npoints,1))
v_x=np.zeros((npoints,1))
v_y=np.zeros((npoints,1))
r=1
dt=1
x[0]=1.
y[0]=0.
v_x[0]=-1.
v_y[90]=-1.
v_x[180]=1.
v_y[270]=1.
for step in range(0,npoints-1):
v_x[step+1]=v_x[step]-4*pi**2*x[step]/(r**3)*dt
x[step+1]=x[step]+v_x[step+1]*dt
v_y[step+1]=v_y[step]-4*pi**2*y[step]/(r**3)*dt
y[step+1]=y[step]+v_y[step+1]*dt
plt.plot(x, y)
plt.axis([-100, 100, -100, 100])
plt.ylabel('y-axis')
plt.xlabel('x-axis')
plt.show()
Thanks for your help :)