# rotation matrix in quaternion representation

is the the rotation matrix corresponding to the quaternion different from the rotation matrix corresponding to the quaternion error (between desired and actual value) ?

Let $\mathrm{Q}$ be the quaternion and the dynamic attitude system represented as $$\dot{\mathrm{Q}}(t)=\frac{1}{2}\mathrm{Q}(t)\otimes\overline{\Omega}(t)\ ,\hspace{1cm}(1)$$

$$J\dot{\Omega}(t)=-\Omega(t)\times J\Omega(t)+u(t)+d(t)\ ,$$ where $J\in R^{3\times 3}$ denotes the inertia matrix of the body and satisfies $J=J^{T}>0, \overline{\Omega}=(0,\ \Omega)$ , and $\Omega\in R^{3}$ is the angular velocity vector of the body in the body-fixed frame, $u(t)\in R^{3}$ is the control torque vector, and $d(t)\in R^{3}$ is the external

disturbance vector. The attitude quaternion $\mathrm{Q}(t) \in R^{4}$ is defined by $\mathrm{Q}(t)=(q_{0}(t),\ q_{1}(t),\ q_{2}(t),\ q_{3}(t))^{T}=(q_{0}(t),\ q_{v}(t))^{T}$ and the Euclidean norm $\Vert \mathrm{Q}(t)\Vert_{2}=1, \forall t\geq 0$. Jf $\mathrm{Q}_{d}$ is the desired quaternion written in dynamic form as $$\displaystyle \dot{\mathrm{Q}}_{d}(t)=\frac{1}{2}\mathrm{Q}_{d}(t)\otimes\overline{\Omega}_{d}(t)\hspace{1cm}(2)$$ with $\overline{\Omega}_{d}=(0,\ \Omega_{d}), \Omega_{d}\in R^{3}$ is the desired angular velocity The quaternion error in multiplicative form is $$\mathrm{Q}_{e}(t)=\mathrm{Q}_{d}^{-1}(t)\otimes \mathrm{Q}(t) \hspace{1cm}(3)$$ or $$\mathrm{Q}_{d}(t)\otimes \mathrm{Q}_{e}(t)=\mathrm{Q}(t) . \hspace{1cm}(4)$$ Then the derivative of the above equation gives $$\dot{\mathrm{Q}}_{d}(t)\otimes \mathrm{Q}_{e}(t)+\mathrm{Q}_{d}(t)\otimes\dot{\mathrm{Q}}_{e}(t)=\dot{\mathrm{Q}}(t) , \hspace{1cm} (5)$$ which leads to

$\displaystyle \dot{\mathrm{Q}}_{d}(t)\otimes \mathrm{Q}_{e}(t)+\mathrm{Q}_{d}(t)\otimes\dot{\mathrm{Q}}_{e}(t)=\frac{1}{2}\mathrm{Q}(t)\otimes\overline{\Omega}(t)$ ,

$\dot{\mathrm{Q}}_{e}(t)$ $$=\displaystyle \frac{1}{2}(\mathrm{Q}_{d}^{-1}(t)\otimes \mathrm{Q}(t)\otimes\overline{\Omega}(t))-\mathrm{Q}_{d}^{-1}(t)\otimes\dot{\mathrm{Q}}_{d}(t)\otimes \mathrm{Q}_{e}(t)\ , \hspace{1cm} (6)$$

$$\displaystyle \dot{\mathrm{Q}}_{e}(t)=\frac{1}{2}(\mathrm{Q}_{e}(t)\otimes\overline{\Omega}(t)-\overline{\Omega}_{d}(t)\otimes \mathrm{Q}_{e}(t)) ;$$ then, $$\displaystyle \dot{\mathrm{Q}}_{e}(t)=\frac{1}{2}\mathrm{Q}_{e}(t)\otimes(\overline{\Omega}(t)-\mathrm{Q}_{e}^{-1}(t)\otimes\overline{\Omega}_{d}(t)\otimes \mathrm{Q}_{e}(t)) . \hspace{1cm}(7)$$ Let $$\mathrm{Q}_{e}^{-1}(t)\otimes\overline{\Omega}_{d}(t)\otimes \mathrm{Q}_{e}(t)=\overline{\Omega}_{d}^{*}(t) \hspace{1cm}(8)$$ with $$\Omega_{d}^{*}(t)=R^{T}(\mathrm{Q}_{e}(t))\Omega_{d}(t) . \hspace{1cm} (9)$$ Using Rodriguez formula one can define the rotation matrix in quaternion representation [15, 16]: $$R^{T}(\mathrm{Q}_{e}(t))=I+2S(\mathrm{Q}_{e}(t))+2S^{2}(\mathrm{Q}_{e}(t)) . \hspace{1cm}(10)$$ $S$ is skew-symmetric which satisfies the condition $-S=S^{T}.$ Let an auxiliary angular velocity be defined as $$\Omega_{\mathrm{a}\mathrm{u}\mathrm{x}}(t)=\Omega(t)-\Omega_{d}^{*}(t)\ ,\hspace{1cm}(11)$$

$$\dot{\Omega}_{\mathrm{a}\mathrm{u}\mathrm{x}}(t)=\dot{\Omega}(t)-\dot{\Omega}_{d}^{*}(t)\ ,$$ so the system in quaternion error can be represented as $$\displaystyle \dot{\mathrm{Q}}_{e}(t)=\frac{1}{2}\mathrm{Q}_{e}(t)\otimes\overline{\Omega}_{\mathrm{a}\mathrm{u}\mathrm{x}}(t) ; \hspace{1cm}(12)$$

in equation (10) why the rotation matrix of quaternion error is different from the rotation matrix of the quaternion ?

let $I_{3}$ is the $3\times 3$ identity matrix, and the matrix $$q\times=\left(\begin{array}{lll} 0 & -q_{3} & q_{2}\\ q_{3} & 0 & -q_{\mathrm{l}}\\ -q_{2} & q_{\mathrm{l}} & 0 \end{array}\right)$$ carries out the cross product. the rotation matrix corresponding to $q$ is then $$R=(q_{0}^{2}-\Vert q\Vert^{2})I_{3}+2qq^{T}+2q_{0}q\times$$

equations (1) to (12) are from this research paper https://www.hindawi.com/journals/mpe/2016/8573235/

another question this symbol $\otimes$ denotes matrix multiplication form or the Kronecker product ?

It appears to me that your equation (10) is in error. It should be $$\mathbf R = \mathbf I + 2q_0 \operatorname{\mathbf{S}}(\boldsymbol q_v) + 2\operatorname{\mathbf{S}}(\boldsymbol q_v)^2\tag{10'}$$ where $q_0$ and $\boldsymbol q_v$ are the real scalar and imaginary vector parts of the quaternion $\mathrm Q$ and $\operatorname{\mathbf{S}}(\boldsymbol a)$ is the skew symmetric cross product matrix corresponding to the vector $\boldsymbol a = [a_x,a_y,a_z]^\top$: $$\operatorname{\mathbf{S}}(\boldsymbol a) = \begin{bmatrix}0&-a_z&a_y\\a_z&0&-a_x\\-a_y&a_x&0\end{bmatrix}$$ The vector triple product identity yields an alternative way to write the square of the skew-symmetric cross product matrix: $\operatorname{\mathbf{S}}(\boldsymbol a)^2 = \boldsymbol a\boldsymbol a^\top - a^2\mathbf I$. With this, equation (10') becomes \begin{aligned} \mathbf R &= \mathbf I + 2q_0 \operatorname{\mathbf{S}}(\boldsymbol q_v) + 2\left(\boldsymbol q_v \boldsymbol q_v^\top - ||\boldsymbol q_v||^2 \mathbf I\right) \\ &= (1-2|\boldsymbol q_v||^2)\mathbf I + 2q_0 \operatorname{\mathbf{S}}(\boldsymbol q_v) + 2\boldsymbol q_v \boldsymbol q_v^\top \\ &=(q_0^2-|\boldsymbol q_v||^2)\mathbf I + 2q_0 \operatorname{\mathbf{S}}(\boldsymbol q_v) + 2\boldsymbol q_v \boldsymbol q_v^\top \end{aligned} The form form in the above, which is equivalent to your expression near the end of the question, uses the fact that $q_0^2 + ||\boldsymbol q_v||^2 \equiv 1$ for a unit quaternion.

Finally, as mentioned in the other answer, the symbol $\otimes$ as used in the referenced paper represents quaternion multiplication: $$(a_0,\boldsymbol a_v)\otimes(b_0,\boldsymbol b_v) = (a_0b_0-\boldsymbol a_v\cdot \boldsymbol b_v,\,a_0\boldsymbol b_v + b_0\boldsymbol a_v +\boldsymbol a_v\times\boldsymbol b_v)$$ Personally, I prefer no symbol at all (i.e., implied multiplication).

A note on conventions:

Some people use unit quaternions such that $\mathrm Q \boldsymbol v \mathrm Q^\ast$ transforms the vector $\boldsymbol v$ from its representation in frame A to its representation in frame B; others use $\mathrm Q^\ast \boldsymbol v \mathrm Q$. Both are correct so long as one is consistent; I use the former scheme. There are also issues with physically rotating versus transforming a vector. One needs to take care. Different schemes can result in sign changes in equation (10'). For example, one often sees $$\mathbf R = \mathbf I - 2q_0 \operatorname{\mathbf{S}}(\boldsymbol q_v) + 2\operatorname{\mathbf{S}}(\boldsymbol q_v)^2$$ Different conventions can also result in changes in the sign and/or changes in the multiplication order in expressions for the quaternion time derivative.

Answering your last question first, the $\otimes$ stands for quaternion multiplication (not Kronecker multiplication) as I said in this answer.

As I read that paper, they are defining a quaternion $Q_e$ which represents the "error", i.e. the rotation between the actual orientation $Q$ and the desired orientation $Q_d$. In the process of developing an equation of motion for $\dot{Q}_e$, it turns out to be useful to define a quantity, in eqn (8) $$\overline{\Omega}_d^* = Q_e^{-1}\otimes\overline{\Omega}_d\otimes Q_e$$ As you know, $\overline{\Omega}_d$ is a quaternion representing the 3-component vector $\Omega_d$, supplemented by a zero in the zeroth position. The above expression is actually a disguised version of the usual formula for rotating a vector from one frame to another, using a $3\times 3$ rotation matrix, and this is expressed in eqn (9) $$\Omega_d^* = R_e^T \Omega_d$$ where $R_e^T=R^T(Q_e)$ In other words, eqn (9) is exactly equivalent to eqn (8).

All you need is the formula for $R_e=R(Q_e)$, or its transpose $R^T$, in terms of the quaternion parameters. In the paper, they give you this using Rodriguez' formula, but one can also derive it by brute force, expressing quaternion multiplication in two ways following the pattern of this answer \begin{align} C &= A \otimes B \\ \begin{pmatrix} c_0 \\ c_1 \\ c_2 \\ c_3 \end{pmatrix} &= \begin{pmatrix} a_0 & -a_1 & -a_2 & -a_3 \\ a_1 & a_0 & -a_3 & a_2 \\ a_2 & a_3 & a_0 & -a_1 \\ a_3 & -a_2 & a_1 & a_0 \end{pmatrix} \begin{pmatrix} b_0 \\ b_1 \\ b_2 \\ b_3 \end{pmatrix} \\ &= \begin{pmatrix} b_0 & -b_1 & -b_2 & -b_3 \\ b_1 & b_0 & b_3 & -b_2 \\ b_2 & -b_3 & b_0 & b_1 \\ b_3 & b_2 & -b_1 & b_0 \end{pmatrix} \begin{pmatrix} a_0 \\ a_1 \\ a_2 \\ a_3 \end{pmatrix} \end{align} It is an instructive exercise to use the first of these formulae for the first $\otimes$, and the second of the formulae for the second $\otimes$, in eqn (8). If you do this carefully the right hand side of eqn (8) will become a matrix-vector multiplication of the following form: $$\begin{pmatrix} \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot \end{pmatrix} \begin{pmatrix} \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot \end{pmatrix} \begin{pmatrix} 0 \\ \Omega_{d,1} \\ \Omega_{d,2} \\ \Omega_{d,3} \end{pmatrix}$$ where each dot represents an element of $Q_e$. Multiply the two $4\times 4$ matrices together to give a $4\times 4$ matrix, of which the important part, the lower-right $3\times3$ submatrix, will be the desired rotation matrix $R_e^T=R^T(Q_e)$. Each term of the $3\times3$ matrix will be quadratic in the elements of $Q_e$.

In any case, the answer to your question is that the quantity required in equation (9), and defined in eqn (10) is indeed the rotation matrix which corresponds to the "error" quaternion $Q_e$, not the rotation matrix corresponding to the orientation itself, $Q$. (Of course, a similar formula applies to any rotation or orientation, connecting the quaternion with the equivalent rotation matrix).

for equation (10) is that true: $$R^{T}(\mathrm{Q}_{e}(t))= \begin{bmatrix} q_{0}^{2}+q_{1}^{2}-q_{2}^{2}-q_{3}^{2} & 2(q_{1}q_{2}-q_{0}q_{3}) & 2(q_{0}q_{2}+q_{1}q_{3})\\ 2(q_{1}q_{2}+q_{0}q_{3}) & q_{0}^{2}-q_{1}^{2}+q_{2}^{2}-q_{3}^{2} & 2(q_{2}q_{3}-q_{0}q_{1}) \\ 2(q_{1}q_{3}-q_{0}q_{2}) & 2(q_{0}q_{1}+q_{2}q_{3}) & q_{0}^{2}-q_{1}^{2}-q_{2}^{2}+q_{3}^{2} \\ \end{bmatrix}$$

for the value of the desired angular velocity $\Omega_{d}$ can i take any arbitrary value like $\Omega_{d}=[1.5 ; 1.2 ;1.3]$ or there is such a criteria that should i follow $\Omega_{d}$ is in $rad / sec$

• First, I have to comment that posting additional questions in an answer to your own question is unlikely to work! It is pure chance that I came back here and saw this. You may like to take the tour https://physics.stackexchange.com/tour to learn a bit more about how the site works. Secondly, this question is very close to a "check-my-work" question, which the stackexchange moderators actively discourage see this discussion. – user197851 Aug 5 '18 at 10:45
• Nonetheless, I'll try to answer here. When I work through my brute force method I get the transpose of what you write here. When I evaluate eqn (10)' of David Hammen's answer (which corrects a typo in your original cited paper) but use the skew matrix $\mathbf{S}$ of eqn (23) of that paper (which is the transpose of Hammen's) and interpret the result as your $\mathbf{R}^T$ (whereas he writes $\mathbf{R}$) then I again get the transpose of your answer. Bearing in mind Hammen's note on conventions, I strongly recommend that you check, and double check, yourself! – user197851 Aug 5 '18 at 10:50
• And finally, in response to your last question, where you seem to be asking for advice on what numerical parameters to feed into the calculation, I can't possibly answer that. It depends entirely on what you are doing with these equations, so it is up to you to figure that out. I can't help. Good luck! – user197851 Aug 5 '18 at 10:52