Advertisement
big_cee223

Robotics

Aug 2nd, 2024
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. import numpy as np
  2.  
  3. np.set_printoptions(precision=3,suppress=True,floatmode='fixed')
  4.  
  5. Rx = np.matrix([[1,0,0],
  6.                 [0,np.cos(90*np.pi/180),-np.sin(90*np.pi/180)],
  7.                 [0,np.sin(90*np.pi/180),np.cos(90*np.pi/180)]])
  8. print("Matrix 1:\n", Rx)
  9. Ry= np.matrix([[np.cos(45*np.pi/180),0,np.sin(45*np.pi/180)],
  10.                 [0,1,0],
  11.                 [-np.sin(45*np.pi/180),0,np.cos(45*np.pi/180)]])
  12. print("Matrix 2:\n", Ry)
  13. Rz = np.matrix([[np.cos(120*np.pi/180),-np.sin(120*np.pi/180),0],
  14.                 [np.sin(120*np.pi/180),np.cos(120*np.pi/180),0],
  15.                 [0,0,1]])
  16. print("Matrix 3:\n", Rz)
  17.  
  18. R=Rz*Rx
  19. print("Matrix Answer :\n", R)
  20.  
  21. XW=np.arccos(R[0,2])
  22. print("Matrix XW : ",XW*180/np.pi)
  23.  
  24. P2=np.matrix([[1],[2],[1]])
  25. P1=R*P2
  26. print("Matrix P1 :\n", P1)
  27. px,py,pz=P1[0,0],P1[1,0],P1[2,0]
  28. absP=np.sqrt(px**2+py**2+pz**2)
  29. uniteP1=P1/absP
  30. print("Matrix absP:\n", absP)
  31. print("Matrix uniteP1:\n", uniteP1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement