# 5.1 Attitude Transformations

In order to better understand the attitude representation and transformation equations defined in Sections 2.3 and 2.4, the example below walks through a simple attitude representation transformation. An orientation of ($\psi = 120^{\circ}$, $\theta = 20^{\circ}$, $\phi = 14^{\circ}$) defined by a (3-2-1) set of Euler angles will be transformed into an attitude represented by the quaternion.

First, the set of Euler angles must be converted into the associated DCM, shown in Equation \ref{eq:appdcm} ($\cos\phi$ and $\sin\phi$ have been abbreviated $\mbox{c}\phi$ and $\mbox{s}\phi$, respectively).

$$\label{eq:appdcm}\begin{split} C_{(3,2,1)}& = R_1(14^{\circ})R_2(20^{\circ})R_3(120^{\circ}) \\\\ & = \begin{bmatrix}c(20^{\circ})c(120^{\circ}) & c(20^{\circ})s(120^{\circ}) & -s(20^{\circ})\\-c(14^{\circ})s(120^{\circ})+s(14^{\circ})s(20^{\circ})c(120^{\circ}) & c(14^{\circ})c(120^{\circ})+s(14^{\circ})s(20^{\circ})s(120^{\circ}) & s(14^{\circ})c(20^{\circ})\\s(14^{\circ})s(120^{\circ})+c(14^{\circ})s(20^{\circ})c(120^{\circ}) & -s(14^{\circ})c(120^{\circ})+c(14^{\circ})s(20^{\circ})s(120^{\circ}) & c(14^{\circ})c(20^{\circ})\end{bmatrix}\end{split}$$

This results in a DCM of

$$C_{(3,2,1)}=\left[\begin{matrix}-0.1954&0.9192&-0.3420\\-0.9663&-0.1208&0.2273\\0.1676&0.3749&0.9118\end{matrix}\right]$$

Each of the quaternion elements must then be calculated to determine the maximum value of the four quaternion elements.

$$\label{eq:appquat}\begin{split}q_1^2 &=\frac{1}{4}{(1-0.1954+0.1208-0.9118)}=0.0034\\q_2^2 &=\frac{1}{4}{(1+0.1954-0.1208-0.9118)}=0.0407\\q_3^2 &=\frac{1}{4}{(1+0.1954+0.1208+0.9118)}=0.5570\\q_4^2 &=\frac{1}{4}{(1-0.1954-0.1208+0.9118)}=0.3989\\\end{split}$$

As shown in Equation \ref{eq:appquat}, the $q_3$ element provides the maximum value of the four quaternion elements. Therefore, the formula corresponding to $q_3$ will be used to compute the remaining quaternion terms.

$$\boldsymbol{q} = \frac{1}{4q_3}\begin{bmatrix} C_{31}+C_{13}\\ C_{23}+C_{32}\\ 4q_3^2\\ C_{12}-C_{21} \end{bmatrix} = \frac{1}{4(0.7463)}\begin{bmatrix} 0.1676+(-0.3420)\\ 0.2273+0.3749\\ 4(0.5570)\\ 0.9192-(-0.9663) \end{bmatrix} = \begin{bmatrix} -0.0584\\ 0.2017\\ 0.7463\\ 0.6316 \end{bmatrix}$$