Kinematic equation for spacecraft using quaternion I have been trying to find the expression of the quaternion kinematic equation for a satellite in circular orbit in the rotating frame, but I could not find any reference where the derivation was presented.
I have the differential equation in terms of Euler angles: (with n the mean motion) $$ n = \frac{2\pi}{P} \mbox{ with P the orbital period}$$

And I have the regular differential equation in terms of quaternion:

What is the full equation in the rotating frame?
 A: Equations of motion with quaternion 
\begin{align*}
  \Theta\,\dot{\vec{\omega}}&=\vec{\tau}-\tilde{\omega}\,\Theta\,\vec{\omega}&(1)\\
  &\text{with:}\\
  \tilde{\omega}&=
  \begin{bmatrix}
    0 & -\omega_z & \omega_y \\
    \omega_z & 0 & -\omega_x \\
    -\omega_y & \omega_x & 0 \\
  \end{bmatrix}\\\\
  &\vec{\omega}\quad\text{Angular velocity }\\
  &\Theta=\Theta(\vec{z})\quad \text{Inertia Tensor}\\
  &\vec{\tau}=\vec{\tau}(\vec{z}\,,\dot{\vec{z}}\,,t)\quad \text{External torques }\\
  &\text{and}\\
  \vec{z}&=\begin{bmatrix}
    a \\
    b \\
    c \\
    d \\
  \end{bmatrix},\quad
  \text{$4\times 1$ Quaternion vector with: }\quad \vec{z}^T\,\vec{z}=1\\\\
   &\text{Kinematic}\\
 \dot{\vec{z}}&=\frac{1}{2}
 \begin{bmatrix}
   0 & -\vec{\omega}^T \\
   \vec{\omega} & \tilde{\omega} \\
 \end{bmatrix}\,\vec{z}&(2)\\\\
  &\text{Rotation matrix $R$}\\
 R&=\left[ \begin {array}{ccc} {a}^{2}+{b}^{2}-{c}^{2}-{d}^{2}&-2\,ad+2\,
bc&2\,ac+2\,bd\\  2\,ad+2\,bc&{a}^{2}+{c}^{2}-{d}^{2}
-{b}^{2}&-2\,ab+2\,cd\\  -2\,ac+2\,bd&2\,ab+2\,cd&{a}
^{2}+{d}^{2}-{b}^{2}-{c}^{2}\end {array} \right]
\quad\text{and  } R^T\,R=I
\end{align*}
Simulation
To fulfill the requirement that $\vec{z}^T\,\vec{z}=1$ we extent equation (2) with a "P controller element"
\begin{align*}
  \dot{\vec{z}}&=\frac{1}{2}\begin{bmatrix}
   0 & -\vec{\omega}^T \\
   \vec{\omega} & \tilde{\omega} \\
 \end{bmatrix}\,\vec{z}+\frac{P}{2}\left(1-\vec{z}^T\,\vec{z}\right)\,\vec{z}&(3)\\\\
&\text{Calculations steps:}\\\\
 &\text{Step I: Give the initial condition for $t=0$}\Rightarrow\quad \vec{\omega}(0)\,,\vec{z}(0)\\
 &\text{Step II solve equation (1) for } \dot{\vec{\omega}}\\
 &\text{Step III } \vec{\omega}=\int \dot{\vec{\omega}}\,dt+\vec{\omega}(0)\\
 &\text{Step IV calculate equation (3)}\\
 &\text{Step V} \quad \vec{z}=\int \dot{\vec{z}}\,dt +\vec{z}(0)\\
\end{align*}
