Hopefully this writeup can help demystify rigid body dynamics for those who have a hard time remembing their first undergraduate M.E. class.

## Time derivative of a rotation matrix

Let’s start with the basics, the same vector expressed in two coordinate frames. We’ll call `x_b`

the position of a point in some body frame and `x_i`

that same point but expressed in an inertial frame. They are related by a matrix which converts body coordinates to inertial ones, `R_b2i`

```
x_i = R_b2i * x_b
```

Okay, nothing too crazy yet. Let’s also assume `x_b`

is a fixed point on our rigid body, which is to say it is not moving in the body frame.

Now, what happens when we take a time derivative of `x_i`

?

```
x_i_dot = R_b2i * x_b_dot + (R_b2i)_dot * x_b
```

But remember, `x_b`

does not move in the body frame. This means `x_b_dot = 0`

.

**eq1**

```
x_i_dot = (R_b2i)_dot * x_b
```

Now we just need to figure out what to make of the time derivative of a rotation matrix, `(R_b2i)_dot`

.

Recall the simple relationship between linear and angular velocity:

```
v = omega X r
```

We can use this equation to find the *inertial* velocity of `x_b`

expressed in the body frame:

```
x_b_dot_inertial = omega_b X x_b
```

Where `omega_b`

is the angular velocity of the body frame expressed in the body frame. Now to convert `x_b_dot_inertial`

into `x_i`

is a simple matter:

```
x_i_dot = R_b2i * x_b_dot_inertial = R_b2i * omega_b X x_b
```

We can further take advantage of the skew symmetric matrix and define a matrix `omega_b_cross`

which has the property:

```
omega_b_cross * r = omega_b X r
```

Putting this all together we have:

**eq2**

```
x_i = R_b2i * omega_b_cross * x_b
```

Now we can combine **eq1** and **eq2** to solve for `(R_b2i)_dot`

**eq3**

```
(R_b2i)_dot = R_b2i * omega_b_cross
```

## Newton-Euler equations

The Newton-Euler equations describe the rotation and translation of a rigid body under the influence of a force and moment. With the math described in the last section figuring them out is a simple matter.

We must first remember that momentum (angular and linear) is *only conserved in an inertial frame*. If we were interested in equations that worked in an inertial frame we’d be done and could resort to the simple equations everyone learns in highschool physics

```
F = m * a
tau = I * omega_dot
```

Unfortunately the inertial frame is often a very inconvenient place to work in. For example, the moment of inertia tensor `I`

will very likely be changing as our rigid body spins in an inertial frame. Let’s see if we can express the same type of equations but in the more convenient body frame.

Let’s begin with conservation of momentum using body frame velocities which are rotated into the inertial frame by `R_b2i`

```
p_i = R_b2i * m * v_b
h_i = R_b2i * I * omega_b
```

Now we can take a time derivative and use the fact that the time derivative of linear and angular momentum are defined as force and torque, respectively

```
F_i = R_b2i * m * a + (R_b2i)_dot * m * v_b
tau_i = R_b2i * I * omega_b_dot + (R_b2i)_dot * I * omega_b
```

And using **eq3**

```
F_i = R_b2i * m * a + R_b2i * omega_b_cross * m * v_b
tau_i = R_b2i * I * omega_b_dot + R_b2i * omega_b_cross * I * omega_b
```

Now we simply multiply both sets of equations by `R_i2b`

**eq4**

```
F_b = m * a + m * omega_b X v_b
tau_b = I * omega_b_dot + omega_b X I * omega_b
```

And there you have it, the equations which relate linear and angular acceleration expressed in the body frame with forces and torques which are also expressed in the body frame.