Advertisement
jukaukor

MoonEarthSun.py

Jun 7th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. # Moon orbits Earth, Earth orbits Sun
  2. # Juhani Kaukoranta 7.6.2018
  3. import matplotlib.pyplot as plt
  4. from math import pi
  5. import numpy as np
  6.  
  7. u = np.arange(0,2*pi,0.01)
  8. # Moon orbit
  9. xM = 8*np.cos(u) + np.cos(13.4*u)
  10. yM = 8*np.sin(u) + np.sin(13.4*u)
  11. plt.plot(xM,yM, label = "Moon")
  12.  
  13. # Earth orbit Sun
  14. xE = 8*np.cos(u)
  15. yE = 8*np.sin(u)
  16. plt.plot(xE,yE, label = "Earth")
  17. # Sun plot
  18. plt.plot(0,0,'yo')
  19.  
  20. plt.title('Moon orbit Earth, Earth orbit Sun')
  21. plt.legend()
  22. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement