# Using higher order derivatives of quaternions in equations of motion

It is common to look at the orientation of a rigid body in term of a quaternion which encodes an axis and angle with a vector and scalar.

$$\boldsymbol{q} = \pmatrix{ \boldsymbol{\hat{z}} \sin\left( \tfrac{\theta}{2} \right) \\ \cos \left( \tfrac{\theta}{2} \right)} \tag{1}$$

and then it is common to convert the rotational velocity vector $$\boldsymbol{\vec{\omega}}$$ into a time derivative of the orientation for use in simulation integrations.

$$\dot{\boldsymbol{q}} = \tfrac{1}{2} \pmatrix{ \boldsymbol{\vec{\omega}} \\ 0 } \boldsymbol{q} \tag{2}$$

$$\ddot{\boldsymbol{q}} = \tfrac{1}{2} \pmatrix{ \boldsymbol{\vec{\alpha}} \\ 0} \boldsymbol{q} + \dot{\boldsymbol{q}} \boldsymbol{q}^{-1} \dot{\boldsymbol{q}} \tag{3}$$

What I am asking about is keeping the angular quantities in quaternion form ($$\boldsymbol{q}$$, $$\dot{\boldsymbol{q}}$$ and $$\ddot{\boldsymbol{q}}$$) for direct use in equations of motion and kinematics, by deriving the regular rotational vectors from (2) and its derivative (3)

$$\pmatrix{\boldsymbol{\vec{\omega}} \\ 0} = 2 \dot{\boldsymbol{q}} \boldsymbol{q}^{-1} \tag{4}$$ $$\pmatrix{\boldsymbol{\vec{\alpha}} \\ 0} = 2 \left( \ddot{\boldsymbol{q}} - \dot{\boldsymbol{q}} \boldsymbol{q}^{-1} \dot{\boldsymbol{q}} \right) \boldsymbol{q}^{-1} \tag{5}$$

So that angular momentum would be on the form of $$\pmatrix{\boldsymbol{\vec{L}} \\ 0} = \mathcal{I}\, \dot{\boldsymbol{q}} \tag{6}$$

with $$\mathcal{I}$$ being the appropriate 4×4 form making (6) a matrix vector product type of calculation.

Similarly the rotational equations of motion would be

$$\pmatrix{ \boldsymbol{\vec{\tau}} \\ 0} = \mathcal{I} \ddot{\boldsymbol{q}} + \underbrace{ \boldsymbol{u} }_{\dot{\boldsymbol{q}}\text{ related terms}} \tag{7}$$

In the spirit of Hamilton, I think there might be some significance to the structure of $$\mathcal{I}$$, and I was wondering if anyone knows of any prior work related to this line of thinking.

Practically I know the above would simplify the rigid body integrators (by keeping all rotational terms in 4-vectors and allowing linear algebra to do its thing). But I think, this might provide some insight into the behavior of rigid body orientation, just as the profile of translational accelerations gives us insight into velocities and displacements.

• q is a vector so what is $q^{–1}$ ?
– Eli
Commented Sep 10, 2020 at 14:30
• $\boldsymbol{q}$ is a quaternion and $\boldsymbol{q}^{-1}$ is the inverse, such that $$\boldsymbol{q} \boldsymbol{q}^{-1} = \pmatrix{ \vec{0} \\ 1 }$$ yields the identity (null rotation). Commented Sep 10, 2020 at 14:55
• $\vec{q}$ is a $4 \times 1$ vector ? $\vec{q}^{-1}$ is not defined
– Eli
Commented Sep 10, 2020 at 14:58
• @Eli - no $\vec{q}$ is not a vector. It is quaternion that contains a vector and a scalar. See this article on how the inverse is defined. Commented Sep 10, 2020 at 19:45

$$\vec{z}=\begin{bmatrix} a(t) \\ b(t) \\ c(t) \\ d(t) \\ \end{bmatrix}= \begin{bmatrix} a \\ \vec{w} \\ \end{bmatrix}$$

where $$\vec{z}\cdot\vec{z}=1$$

you obtain:

$$\begin{bmatrix} 0 \\ \vec{\omega} \\ \end{bmatrix}=2\, \underbrace{\begin{bmatrix} a & \vec{w}^T \\ -\vec{w} & a\,I_3+\tilde{w} \\ \end{bmatrix}}_{Q (4\times 4)}\,\underbrace{\begin{bmatrix} \dot{a} \\ \vec{\dot w} \\ \end{bmatrix}}_{\vec{\dot{z}}}\tag 1$$

where $$Q^T\,Q=I_4$$, thus $$Q$$ matrix is orthogonal matrix , $$\vec{\omega}$$ is the angular velocity vector and $$I_3$$ is a $$3\times 3$$ unity matrix.

$$\tilde{w}=\left[ \begin {array}{ccc} 0&-w_{{z}}&w_{{y}}\\ w_{ {z}}&0&-w_{{x}}\\ -w_{{y}}&w_{{x}}&0\end {array} \right]$$.

for numerical simulation you can obtain from equation (1)

$$\vec{\dot{z}}=\frac 12 \,\begin{bmatrix} 0 & -\vec{\omega}^T \\ \vec{\omega} & -\tilde{\omega} \\ \end{bmatrix}\,\vec{z}+\frac{P}{2}\,(1-\vec{z}\,\cdot{\vec{z}})\,\vec{z}\tag 2$$

where the second part of the RHS is to fulfill the requirement that $$\vec{z}\cdot\vec{z}$$ must be equal to one.

Equation (2) together with the Euler equations are the EOM's, the separation between the kinematic equation (2) and the Euler equation, make the EOM's simple

Of course you can use equation (1) in the Euler equations, but I don't see how you get the requirement that $$\vec{z}\cdot\vec{z}$$ must be equal to one ?.

The Euler Equations:

$$I\,\vec{\dot \omega}+\vec{\omega}\,\times (I\,\vec{ \omega})=\vec{\tau}$$

• What is $P$ in (2)? Commented Sep 10, 2020 at 20:02
• P is a constant (PID Proportional part of the Controller)
– Eli
Commented Sep 11, 2020 at 7:27
• So if I understand correctly you suggest bringing by (4) into a matrix/vector operation, and then use it for integration, but with a artificial term that enforces the unit quaternion constraint. That answers another question of mine (of the proper way to integrate rotations), but in this case I was asking about doing something similar for $\dot{\vec{\omega}}$ (one more derivative up from (4) which is (5)) and using it into EOM directly. Commented Sep 11, 2020 at 13:10
• yes the controller is necessary to fulfill the norm of $\vec{z}$. you can do it, but because you obtain second order differential equations $\vec{\ddot z}=...$ you have to integrate this equation twice to get $\vec{z}$, the problem that i see ,is how you fulfill the requirement $\vec{z}\cdot \vec{z}=1$ ?, also your equations of motion are huge compare with my solution
– Eli
Commented Sep 11, 2020 at 13:39