Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. def get_rotation_matrix(axis_name, theta):
  2. matrices = {
  3. "x":
  4. [[1, 0, 0],
  5. [0, cos(theta), -sin(theta)],
  6. [0, sin(theta), cos(theta)]],
  7. "y":
  8. [[cos(theta), 0, sin(theta)],
  9. [0, 1, 0],
  10. [-sin(theta), 0, cos(theta)]],
  11. "z":
  12. [[cos(theta), -sin(theta), 0],
  13. [sin(theta), cos(theta), 0],
  14. [0, 0, 1]]
  15. }
  16. return matrices[axis_name]
  17.  
  18. def matmul(a, b):
  19. n = len(a)
  20. m = len(b)
  21. assert len(a[0]) == m
  22. p = len(b[0])
  23. c = []
  24. for i in range(n):
  25. row = []
  26. for j in range(p):
  27. row.append(sum(a[i][k]*b[k][j] for k in range(m)))
  28. c.append(row)
  29. return c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement