JoelSjogren

Untitled

Sep 8th, 2017
351
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. from scipy.spatial import ConvexHull
  4.  
  5. #a = [0, 1, 1j, 0.7+0.8j]
  6. #a = [0, 1, 2, 3, 4]
  7. #a = [0, 1] * 3
  8. #a = [0, 1, .5+.5j*3**.5] * 30
  9. a = [0, 1, 2] * 30
  10.  
  11. p = np.array([1])
  12.  
  13.  
  14. for i, ai in enumerate(a):
  15. p = np.polyint(p)
  16. p = np.polysub(p, np.polyval(p, ai))
  17.  
  18. r = np.roots(p)
  19. plt.plot(np.real(r), np.imag(r), 'o', label=str(ai))
  20. print('p', p, 'r', r)
  21.  
  22. if i == 0:
  23. continue
  24. elif i == 1:
  25. plt.fill(np.real(r), np.imag(r), edgecolor="#000000", alpha=0.5)
  26. else:
  27. if i < 5 or i % 20 != 0: continue
  28. points = np.reshape(np.concatenate([np.real(r), np.imag(r)]),
  29. (len(r), 2), order='F')
  30. hull = ConvexHull(points)
  31. print('vert', hull.vertices)
  32. plt.fill(points[hull.vertices, 0], points[hull.vertices, 1],
  33. alpha=0.3)
  34.  
  35. #plt.legend()
  36. plt.show()
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment