Angular acceleration and velocity in 3D

AI Thread Summary
The discussion focuses on implementing angular acceleration and velocity in a rigid-body physics program using quaternions. The author highlights the importance of choosing between left and right quaternion representations for torque, velocity, and orientation, noting that both have their proponents. The equations of motion are presented, emphasizing the need for angular velocity and acceleration to be expressed in the body frame, which complicates calculations due to the rotating frame. A method for propagating the quaternion using a linear approximation is suggested, along with the necessity to normalize the quaternion after each time step to maintain its unit length. The author warns against using the Euler method due to its instability and lack of energy conservation.
Alkatran
Science Advisor
Homework Helper
Messages
959
Reaction score
0
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?
 
Physics news on Phys.org
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 =<br /> \mathcal Q<br /> \bmatrix 0 \\ \boldsymbol x \endbmatrix<br /> \mathcal Q^\star<br />

\bmatrix 0 \\ \boldsymbol x_{rot}\endbmatrix =<br /> \mathcal Q^\star<br /> \bmatrix 0 \\ \boldsymbol x \endbmatrix<br /> \mathcal Q<br />

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} =<br /> -\;\frac 1 2\bmatrix 0 \\ \boldsymbol \omega_{B:I\to B}\endbmatrix<br /> \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<br /> \exp\left(\frac d{dt} \mathcal Q_{I\to B}(t) \delta t\right)<br /> \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<br /> (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:
I have recently been really interested in the derivation of Hamiltons Principle. On my research I found that with the term ##m \cdot \frac{d}{dt} (\frac{dr}{dt} \cdot \delta r) = 0## (1) one may derivate ##\delta \int (T - V) dt = 0## (2). The derivation itself I understood quiet good, but what I don't understand is where the equation (1) came from, because in my research it was just given and not derived from anywhere. Does anybody know where (1) comes from or why from it the...
Back
Top