SHARE
TWEET

Sample script

a guest Feb 6th, 2016 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import matplotlib
  3. import matplotlib.pyplot as plt
  4.  
  5. r = 10.;
  6. h = 2.;
  7.  
  8. x = np.linspace(-r, +r, 1000)
  9. xlarge = np.linspace(-r * 1.5, r*1.5, 1000)
  10.  
  11. u = np.sqrt( r**2 - x**2)
  12. l = -u
  13.  
  14. a = np.sqrt( (1+h/r)**2 - 1.);
  15. right = r + h - a * xlarge;
  16. left  = r + h + a * xlarge;
  17.  
  18. plt.fill(x, u, 'b', alpha=0.3)
  19. plt.fill(x, l, 'b', alpha=0.3)
  20. plt.plot(xlarge, right, color='g');
  21. plt.plot(xlarge, left , color='g');
  22. plt.xlabel("x")
  23. plt.ylabel("y")
  24. plt.title("Horizon; what is it?")
  25. plt.xlim(-r * 1.5, r*1.5)
  26. plt.ylim(-r * 1.5, r*1.5)
  27. plt.show()
RAW Paste Data
Top