# Determine derivatives of angular sequence to rotation matrix

Peter Corke 2021

SymPy code to evaluate the mappings from rotation angle sequences to rotation matrix, then compute the derivatives to determine the mapping from angular rates to angular velocity.

Adjust the next cell to choose the particular angle sequence.


```python
from spatialmath.base import *
from sympy import *
```


```python
# func = eul2r
# angle_names =  ('phi', 'theta', 'psi')

func = lambda Gamma: rpy2r(Gamma, order='yxz')
angle_names = ('alpha', 'beta', 'gamma')

```

Define a symbol for time


```python
t = symbols('t')
```

Define arrays of symbols for the angles, angle as function of time, time derivative of angle as a function of time


```python
angle = []  # names of angles, eg. theta
anglet = []  # angles as function of time, eg. theta(t)
angled = []  # derivative of above, eg. d theta(t) / dt
angledn = []  # symbol to represent above, eg. theta_dot
for i in angle_names:
    angle.append(symbols(i))
    anglet.append(Function(i)(t))
    angled.append(anglet[-1].diff(t))
    angledn.append(i + '_dot')
```

Compute the rotation matrix


```python
R = Matrix(func(anglet))
R
```




$\displaystyle \left[\begin{matrix}\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} + \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} & - \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} + \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} & \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)}\\\sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} & \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} & - \sin{\left(\beta{\left(t \right)} \right)}\\\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} - \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} & \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} + \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} & \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)}\end{matrix}\right]$



Compute its time derivative


```python
Rdot = Matrix(R).diff(t)
Rdot
```




$\displaystyle \left[\begin{matrix}\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} - \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} - \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} & - \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} - \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} & - \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} + \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)}\\- \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} + \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} & - \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} - \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} & - \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)}\\- \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} + \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} - \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} & - \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} - \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} & - \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} - \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)}\end{matrix}\right]$



Get angular velocity vector in terms of angles and angle rates


```python
omega = Matrix(vex(Rdot * R.T))
omega
```




$\displaystyle \left[\begin{matrix}- \frac{\left(\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} + \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)}\right) \left(- \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} - \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)}\right)}{2} - \frac{\left(\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} - \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)}\right) \left(- \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} + \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)}\right)}{2} - \frac{\left(- \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} - \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)}\right) \sin{\left(\beta{\left(t \right)} \right)}}{2} + \frac{\left(- \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} + \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} - \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)}\right) \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)}}{2} + \frac{\left(- \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} - \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)}\right) \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)}}{2} + \frac{\cos^{2}{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)}}{2}\\\frac{\left(\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} + \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)}\right) \left(- \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} - \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)}\right)}{2} - \frac{\left(- \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} + \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)}\right) \left(- \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} - \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)}\right)}{2} - \frac{\left(\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} + \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)}\right) \left(- \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} + \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} - \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)}\right)}{2} + \frac{\left(\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} - \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)}\right) \left(\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} - \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} - \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)}\right)}{2} + \frac{\left(- \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} + \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)}\right) \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)}}{2} - \frac{\left(- \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} - \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)}\right) \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)}}{2}\\\frac{\left(- \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} + \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)}\right) \left(- \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} - \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)}\right)}{2} + \frac{\left(\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} + \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)}\right) \left(- \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} + \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)}\right)}{2} + \frac{\left(- \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} + \cos{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)}\right) \sin{\left(\beta{\left(t \right)} \right)}}{2} - \frac{\left(- \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} - \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)}\right) \cos{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)}}{2} - \frac{\left(\sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\beta{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)} + \sin{\left(\alpha{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)} - \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\gamma{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} + \sin{\left(\beta{\left(t \right)} \right)} \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \alpha{\left(t \right)} - \sin{\left(\gamma{\left(t \right)} \right)} \cos{\left(\alpha{\left(t \right)} \right)} \frac{d}{d t} \gamma{\left(t \right)}\right) \sin{\left(\alpha{\left(t \right)} \right)} \cos{\left(\beta{\left(t \right)} \right)}}{2} - \frac{\sin{\left(\gamma{\left(t \right)} \right)} \cos^{2}{\left(\beta{\left(t \right)} \right)} \frac{d}{d t} \beta{\left(t \right)}}{2}\end{matrix}\right]$



For each element of this 3x1 matrix get the coefficients of each angle derivative


```python
A = Matrix.zeros(3,3)
for i in range(3):
    e = omega[i,0].expand()
    for j in range(3):
        A[i, j] = e.coeff(angled[j])
```

The result is a 3x3 matrix. Mapping from angle rates to angular velocity. We subsitute angle as a function of time to plain angle, then simplify.


```python
A = trigsimp(A.subs(a for a in zip(anglet, angle)))
A
```




$\displaystyle \left[\begin{matrix}\sin{\left(\gamma \right)} \cos{\left(\beta \right)} & \cos{\left(\gamma \right)} & 0\\- \sin{\left(\beta \right)} & 0 & 1\\\cos{\left(\beta \right)} \cos{\left(\gamma \right)} & - \sin{\left(\gamma \right)} & 0\end{matrix}\right]$



Compute the inverse and simplify.  Mapping from angular velocity to angle rates.


```python
Ai = trigsimp(A.inv())
Ai
```




$\displaystyle \left[\begin{matrix}\frac{\sin{\left(\gamma \right)}}{\cos{\left(\beta \right)}} & 0 & \frac{\cos{\left(\gamma \right)}}{\cos{\left(\beta \right)}}\\\cos{\left(\gamma \right)} & 0 & - \sin{\left(\gamma \right)}\\\sin{\left(\gamma \right)} \tan{\left(\beta \right)} & 1 & \cos{\left(\gamma \right)} \tan{\left(\beta \right)}\end{matrix}\right]$



Render as code


```python
pycode(A).replace('ImmutableDenseMatrix', 'np.array')
```




    'np.array([[math.sin(gamma)*math.cos(beta), math.cos(gamma), 0], [-math.sin(beta), 0, 1], [math.cos(beta)*math.cos(gamma), -math.sin(gamma), 0]])'




```python
pycode(Ai).replace('ImmutableDenseMatrix', 'np.array')
```




    'np.array([[math.sin(gamma)/math.cos(beta), 0, math.cos(gamma)/math.cos(beta)], [math.cos(gamma), 0, -math.sin(gamma)], [math.sin(gamma)*math.tan(beta), 1, math.cos(gamma)*math.tan(beta)]])'



Compute the time derivative of `Ai`, from angular acceleration to angle acceleration


```python
Ai = Ai.subs(a for a in zip(angle, anglet))
Ai
```




$\displaystyle \left[\begin{matrix}\frac{\sin{\left(\gamma{\left(t \right)} \right)}}{\cos{\left(\beta{\left(t \right)} \right)}} & 0 & \frac{\cos{\left(\gamma{\left(t \right)} \right)}}{\cos{\left(\beta{\left(t \right)} \right)}}\\\cos{\left(\gamma{\left(t \right)} \right)} & 0 & - \sin{\left(\gamma{\left(t \right)} \right)}\\\sin{\left(\gamma{\left(t \right)} \right)} \tan{\left(\beta{\left(t \right)} \right)} & 1 & \cos{\left(\gamma{\left(t \right)} \right)} \tan{\left(\beta{\left(t \right)} \right)}\end{matrix}\right]$




```python
Ai_dot = trigsimp(Ai.diff(t).subs(a for a in zip(angled, angledn)).subs(a for a in zip(anglet, angle)))
Ai_dot
```




$\displaystyle \left[\begin{matrix}\frac{\frac{\beta_{dot} \sin{\left(\beta \right)} \sin{\left(\gamma \right)}}{\cos{\left(\beta \right)}} + \gamma_{dot} \cos{\left(\gamma \right)}}{\cos{\left(\beta \right)}} & 0 & \frac{\frac{\beta_{dot} \sin{\left(\beta \right)} \cos{\left(\gamma \right)}}{\cos{\left(\beta \right)}} - \gamma_{dot} \sin{\left(\gamma \right)}}{\cos{\left(\beta \right)}}\\- \gamma_{dot} \sin{\left(\gamma \right)} & 0 & - \gamma_{dot} \cos{\left(\gamma \right)}\\\frac{\beta_{dot} \sin{\left(\gamma \right)}}{\cos^{2}{\left(\beta \right)}} + \gamma_{dot} \cos{\left(\gamma \right)} \tan{\left(\beta \right)} & 0 & \frac{\beta_{dot} \cos{\left(\gamma \right)}}{\cos^{2}{\left(\beta \right)}} - \gamma_{dot} \sin{\left(\gamma \right)} \tan{\left(\beta \right)}\end{matrix}\right]$




```python
pycode(Ai_dot).replace('ImmutableDenseMatrix', 'np.array')
```




    'np.array([[(beta_dot*math.sin(beta)*math.sin(gamma)/math.cos(beta) + gamma_dot*math.cos(gamma))/math.cos(beta), 0, (beta_dot*math.sin(beta)*math.cos(gamma)/math.cos(beta) - gamma_dot*math.sin(gamma))/math.cos(beta)], [-gamma_dot*math.sin(gamma), 0, -gamma_dot*math.cos(gamma)], [beta_dot*math.sin(gamma)/math.cos(beta)**2 + gamma_dot*math.cos(gamma)*math.tan(beta), 0, beta_dot*math.cos(gamma)/math.cos(beta)**2 - gamma_dot*math.sin(gamma)*math.tan(beta)]])'




```python

```

c1bf28ee3c2891a091de5de8a70f6f2e221afc53
ipynb
Jupyter Notebook
symbolic/angvelxform.ipynb
dbkmgm/spatialmath-python
8d48e5a21334f9ceac4f549f194c79afaa22a5d7
MIT
symbolic/angvelxform.ipynb
dbkmgm/spatialmath-python
8d48e5a21334f9ceac4f549f194c79afaa22a5d7
MIT
symbolic/angvelxform.ipynb
dbkmgm/spatialmath-python
8d48e5a21334f9ceac4f549f194c79afaa22a5d7
MIT
Qwen/Qwen-72B
1. YES
2. YES