Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_rotation_matrix(axis_name, theta):
- matrices = {
- "x":
- [[1, 0, 0],
- [0, cos(theta), -sin(theta)],
- [0, sin(theta), cos(theta)]],
- "y":
- [[cos(theta), 0, sin(theta)],
- [0, 1, 0],
- [-sin(theta), 0, cos(theta)]],
- "z":
- [[cos(theta), -sin(theta), 0],
- [sin(theta), cos(theta), 0],
- [0, 0, 1]]
- }
- return matrices[axis_name]
- def matmul(a, b):
- n = len(a)
- m = len(b)
- assert len(a[0]) == m
- p = len(b[0])
- c = []
- for i in range(n):
- row = []
- for j in range(p):
- row.append(sum(a[i][k]*b[k][j] for k in range(m)))
- c.append(row)
- return c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement