| import numpy as np | |
| def rotation_matrix_2d(theta): | |
| c, s = np.cos(theta), np.sin(theta) | |
| return np.array([[c, -s], [s, c]]) | |
| def rotation_matrix_3d_z(theta): | |
| c, s = np.cos(theta), np.sin(theta) | |
| return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]]) | |
| def rotation_matrix_3d_y(theta): | |
| c, s = np.cos(theta), np.sin(theta) | |
| return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]]) | |
| def rotation_matrix_3d_x(theta): | |
| c, s = np.cos(theta), np.sin(theta) | |
| return np.array([[1, 0, 0], [0, c, -s], [0, s, c]]) | |