```python
from sympy import *
from sympy.abc import *
init_printing()
from math import *
```


```python
theta, phi, psi
```


```python
Rz = Matrix([[cos(theta),-sin(theta),0],[sin(theta), cos(theta),0], [0,0,1]])
Rz
```


```python
Ry = Matrix([[cos(psi), 0, sin(psi)], [0, 1, 0],[-sin(psi), 0, cos(psi)]])
Ry
```


```python
Rx = Matrix([[1, 0, 0], [0, cos(phi), -sin(phi)], [0, sin(phi), cos(phi)]])
Rx
```


```python
Rz*Ry*Rx
```


```python
import numpy as np
```


```python
np.degrees(np.radians(90))
```


```python
R = (Rz*Ry*Rx).subs([(theta, np.radians(0)), (psi, np.radians(10)), (phi, np.radians(120))])
print(R)
```

    Matrix([[0.984807753012208, 0.150383733180435, -0.0868240888334651], [0, -0.500000000000000, -0.866025403784439], [-0.173648177666930, 0.852868531952443, -0.492403876506104]])



```python
R
```


```python
def deg(R):
    y = atan2(R[2,1], R[2,2])
    p = asin(-R[2,0])
    r = atan2(R[1,0],R[0,0])
    print(r, p, y)
    return np.rad2deg(r), np.degrees(p), np.degrees(y)
```


```python
deg(R)
```


```python
R = R*(Rz*Ry*Rx).subs([(theta, np.radians(120)), (psi, np.radians(0)), (phi, np.radians(0))])
```


```python
deg(R)
```


```python
360 -120
```


```python

```

56b2182501463f18007d4dca7aedc62481c88184
ipynb
Jupyter Notebook
rotation_matrix2.ipynb
taishi107/algorithms
c58b4599dd54d2e7d2eb0cffc1b1426bea37310a
MIT
rotation_matrix2.ipynb
taishi107/algorithms
c58b4599dd54d2e7d2eb0cffc1b1426bea37310a
MIT
rotation_matrix2.ipynb
taishi107/algorithms
c58b4599dd54d2e7d2eb0cffc1b1426bea37310a
MIT
Qwen/Qwen-72B
1. YES
2. YES