satellites.py 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from mpl_toolkits.mplot3d import Axes3D
  4. from mpl_toolkits.mplot3d import proj3d
  5. data = [
  6. ["SAT0", 1346.496594546033, -6631.509574249269, -1784.401979591288],
  7. ["SAT1", 3986.6137971140965, -4309.794821125442, 3652.552861361319],
  8. ["SAT2", 6066.873731024742, 1768.4246674363346, -2645.6457201477174],
  9. ["SAT3", -531.4244577628424, -5725.907186159696, -3873.2462304175233],
  10. ["SAT4", -3029.294804348662, -6060.24715150741, -1163.1126511352572],
  11. ["SAT5", 4235.879179136093, -5048.655863634309, -1330.5861403372983],
  12. ["SAT6", -3213.176589077265, -4782.048496222451, -3740.7862955786086],
  13. ["SAT7", 176.0460873300058, 488.53751332601894, -6717.752685099294],
  14. ["SAT8", 286.49182959607276, 19.39475455789748, -6993.120858082854],
  15. ["SAT9", 6399.451382476649, -2113.9916687975474, -2002.7547869095122],
  16. ["SAT10", 3257.7488038015017, 1981.1452195906668, -5821.828870417848],
  17. ["SAT11", -581.1213836443779, 3374.6766339195256, 5964.093711437812],
  18. ["SAT12", 217.1789623719815, 178.85016316224656, -6843.305647372251],
  19. ["SAT13", 1176.6725366453472, -4957.9575328468, 4380.506198321206],
  20. ["SAT14", -1068.982383556387, 526.9728758308576, 6575.590264183411],
  21. ["SAT15", 1165.7614133253296, 584.8807748235947, 6545.811084796057],
  22. ["SAT16", -5993.097263023728, 2437.0166813209858, 2726.5808375640754],
  23. ["SAT17", -219.2118047031717, -105.032581318871, -6728.36026711676],
  24. ["SAT18", 3868.5717603149724, 4556.803440191685, -3214.801047688104],
  25. ["SAT19", 55.609142839530044, -1439.9935335382188, -6839.854023068437],
  26. ["Start", -2633.5917604717556, -5669.215907008842, -1230.3765435398993],
  27. ["End", -5854.876300459916, -190.38043902511365, -2504.759428517919]
  28. ]
  29. x = [a[1] for a in data]
  30. y = [a[2] for a in data]
  31. z = [a[3] for a in data]
  32. names = [a[0] for a in data]
  33. fig = plt.figure()
  34. ax = fig.add_subplot(111, projection='3d')
  35. ax.scatter(x,y,z)
  36. plotlabels = []
  37. for name,xi,yi,zi in zip(names,x,y,z):
  38. x2, y2, _ = proj3d.proj_transform(xi,yi,zi, ax.get_proj())
  39. h = plt.annotate(name, xy = (x2,y2), xytext=(-20,20), textcoords='offset points', ha = 'right', va = 'bottom',
  40. bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),
  41. arrowprops = dict(arrowstyle = '-', connectionstyle = 'arc3,rad=0'))
  42. plotlabels.append(h)
  43. def update_position(e):
  44. for h,xi,yi,zi in zip(plotlabels, x, y, z):
  45. x2, y2, _ = proj3d.proj_transform(xi,yi,zi, ax.get_proj())
  46. h.xy = x2,y2
  47. h.update_positions(fig.canvas.renderer)
  48. fig.canvas.draw()
  49. fig.canvas.mpl_connect('motion_notify_event', update_position)
  50. ax.set_xlabel('X')
  51. ax.set_ylabel('Y')
  52. ax.set_zlabel('Z')
  53. plt.show()