Guest User

Untitled

a guest
Dec 15th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from mpl_toolkits.mplot3d import Axes3D
  4.  
  5. # algebraic 2-dimensional vector representation
  6. v1 = np.array([ 1, 2])
  7.  
  8. # algebraic 3-dimensional vector representation
  9. v2 = np.array([ 1,2,3])
  10.  
  11. # geometric representation of v1
  12. plt.plot([0,v1[0]],[0,v1[1]])
  13. plt.axis('equal')
  14. plt.plot([-4, 4],[0, 0],'k--')
  15. plt.plot([0, 0],[-4, 4],'k--')
  16. plt.grid()
  17. plt.axis((-4, 4, -4, 4))
  18. plt.show()
  19.  
  20.  
  21. # geometric representation of v2
  22. fig = plt.figure()
  23. ax = fig.gca(projection='3d')
  24. ax.plot([0, v2[0]],[0, v2[1]],[0, v2[2]])
  25.  
  26. # make the plot look nicer
  27. plt.axis('equal')
  28. ax.plot([0, 0],[0, 0],[-4, 4],'k--')
  29. ax.plot([0, 0],[-4, 4],[0, 0],'k--')
  30. ax.plot([-4, 4],[0, 0],[0, 0],'k--')
  31. plt.show()
Add Comment
Please, Sign In to add comment