Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib
  3. import matplotlib.pyplot as plt
  4.  
  5. r = 6371000.
  6. r = 100.
  7. h = 2.
  8. y0 = r + h
  9.  
  10. x = np.linspace(0, 10, 1000)
  11.  
  12.  
  13. a = np.sqrt( (1+x/r)**2 - 1.)
  14.  
  15. xi = ( a * y0 ) / (1 + a**2)
  16. yi = y0 + xi * a
  17.  
  18. phi = np.arctan( yi / xi )
  19. y = r*( np.pi/2 - phi)
  20.  
  21. plt.fill_between(x, 0, y, color='g',alpha=0.3)
  22. plt.plot( x, np.sqrt( (yi-y0)**2 + xi**2), 'r-', label='calculation')
  23. plt.plot( x, np.sqrt(2*r*x + x**2), 'b--', label='wikipedia')
  24. plt.xlabel("height [m]")
  25. plt.ylabel("horizon distance [m]")
  26. plt.title("Horizon; distance? (radius = %.3f)" % r)
  27. plt.legend(loc=2)
  28. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement