# Angular acceleration and velocity in 3D

1. Jul 27, 2007

### Alkatran

I'm trying to write a small rigid-body physics program. I already have the linear forces part done, using Euler's method. This makes it easy to take the current forces and compute the next position.

The issue I'm having is that I don't know how to get the next angular position/velocity from the current torques on the body. If I use quaternions for torque, velocity and orientation, do I just left-multiply my torque rotation quaternions together, then use that to rotate my velocity, then use that to rotate my position?

2. Jul 27, 2007

### D H

Staff Emeritus
First, a word of caution regarding quaternions for rotations. There are many ways to do this. Quaternions can be represented by a scalar and an imaginary vector: $$\mathcal Q = \bmatrix q_s \\ \boldsymbol q_v \endbmatrix$$

Suppose $$\mathcal Q$$ is a unit quaternion. Both of the following forms transform a vector in $$\mathbb R^3$$:

$$\bmatrix 0 \\ \boldsymbol x_{rot}\endbmatrix = \mathcal Q \bmatrix 0 \\ \boldsymbol x \endbmatrix \mathcal Q^\star$$

$$\bmatrix 0 \\ \boldsymbol x_{rot}\endbmatrix = \mathcal Q^\star \bmatrix 0 \\ \boldsymbol x \endbmatrix \mathcal Q$$

The difference between the two forms is whether the the unconjugated quaternion is on the left or the right, hence the terminology left and right quaternions. Some people prefer left quaternions because they chain right to left, exactly the way transformation matrices chain (a good thing). Others prefer right quaternions because they chain left-to-right, which is intuitively more obvious. Those people see the right-to-left chaining of transformation matrices as goofy and something to be discarded. Both sides are often guilty of being unaware that there are two ways to do this. So beware. You have to scrutinize any books or papers you reference to make sure you and the reference are in sync.

BTW, I use left quaternions. They are by far the more prevalent form at NASA JSC. (Marshall uses right quaternions, so go figure.)

Now, about the rotational equations of motion. Denote the attitude quaternion, rotation rate, and rotational acceleration of some body with respect to inertial as $$\mathcal Q_{I\to B}$$, $$\boldsymbol \omega_{B:I\to B}$$, and $$\dot \boldsymbol \omega_{B:I\to B}$$. The B: denotes that the vectors are expressed in the body frame rather than inertial. Vehicles need to know their angular velocity in their own frame, and torques typically arise in the body frame. It is very convenient to represent angular velocity and acceleration in the body frame. However, it is a rotating frame. Since the body frame is rotating, the angular acceleration includes a rotating frame term as well as terms from external torques.

The quaterion derivative is

$$\frac d{dt} \mathcal Q_{I\to B} = -\;\frac 1 2\bmatrix 0 \\ \boldsymbol \omega_{B:I\to B}\endbmatrix \mathcal Q_{I\to B}$$

How to propagate? The above form obviously suggests an exponential form (using the quaternion exponential function!):

$$\mathcal Q_{I\to B}(t+\delta t) \approx \exp\left(\frac d{dt} \mathcal Q_{I\to B}(t) \delta t\right) \mathcal Q_{I\to B}(t)$$

However, if the time steps are sufficiently small, a linear approximation can be used since the quaternion exponential behaves analogously to the complex and real exponential:

$$\mathcal Q_{I\to B}(t+\delta t) \approx (1+\frac d{dt} \mathcal Q_{I\to B}\delta t) \mathcal Q_{I\to B}(t)$$

One problem with this is that the result is not a unit quaternion. There is a simple solution: normalize the quaternion after each time step.

I will leave the second derivative as an excercise for the reader.

Another word of caution: If you are propagating the quaternion derivative (rather than angular velocity) will need to enforce the fact that the quaternion derivative is normal to the quaternion. The inner product of any constant length vector and its derivative is identically zero.

A final word of caution: Don't use the Euler method. It is never stable. It does not conserve energy. It loses accuracy incredibly quickly. It is easy to understand, which is why it is taught. Learn it and then never, ever, ever, ever use it.

Last edited: Jul 27, 2007