# Applying Neural Networks in Aerial Vehicle Guidance to Simplify Navigation Systems
## 2 Vehicle Modeling
### Navigation
#### 3.1.2 Attitude Determination Algorithm  
Attitude determination can be determined by solving a classical Wahba's problem [42]. An orthonormal base must be defined in both axes systems, B and NED. This orthonormal base is defined for intermediate phases of flight, when signal of the photo-detector is not available and for the terminal phase of flight, when it is available, by unitary vectors \(\vec{i},\vec{j}\) and \(\vec{k}\) expressed in both bases. For the intermediate phases, these unitary vectors are calculated using the speed vector and the gravity vector. Furthermore, for the terminal flight, the line of sight vector and the gravity vector are to be employed. For the intermediate phases, \(fl\), the unitary vectors are defined by expressions (11) and (12). \[\overrightarrow{i_{NED_{fl}}}=\frac{\overrightarrow{v_{NED_{fl}}}}{\left\| \overrightarrow{v_{NED_{fl}}}\right\|},\ \ \overrightarrow{j_{NED_{fl}}}=\frac{\overrightarrow{v_{NED_{fl}}} \times\overrightarrow{s_{NED_{fl}}}}{\left\|\overrightarrow{v_{NED_{fl}}} \times\overrightarrow{s_{NED_{fl}}}\right\|},\ \ \ \overrightarrow{k_{NED_{fl}}}=\frac{ \overrightarrow{i_{NED_{fl}}}\times\overrightarrow{j_{NED_{fl}}}}{\left\| \overrightarrow{i_{NED_{fl}}}\times\overrightarrow{j_{NED_{fl}}}\right\|} \tag{11}\]  
\[\overrightarrow{i_{B_{fl}}}=\frac{\overrightarrow{v_{R}}}{\left\| \overrightarrow{v_{R}}\right\|},\ \ \overrightarrow{j_{B_{fl}}}=\frac{ \overrightarrow{v_{R}}\times\overrightarrow{v_{R}}}{\left\| \overrightarrow{v_{R}}\times\overrightarrow{s_{R}}\right\|},\ \ \overrightarrow{k_{B_{fl}}}=\frac{ \overrightarrow{i_{B_{fl}}}\times\overrightarrow{i_{B_{fl}}}}{\left\| \overrightarrow{i_{B_{fl}}}\times\overrightarrow{j_{B_{fl}}}\right\|} \tag{12}\]  
During the terminal guidance phase, \(tf\), when the photo-detector is receiving information, a new set of unitary vectors is obtained by Equations (13) and (14). \[\overrightarrow{i_{NED_{tf}}}=\frac{\overrightarrow{ LOS_{NED_{f}}}}{\left\| \overrightarrow{ LOS_{NED_{f}}}\right\|},\ \ \overrightarrow{j_{NED_{tf}}}=\frac{ \overrightarrow{ LOS_{NED_{f}}}\times\overrightarrow{s_{NED_{fl}}}}{\left\| \overrightarrow{ LOS_{NED_{f}}}\times\overrightarrow{s_{NED_{fl}}}\right\|},\ \ \ \overrightarrow{k_{NED_{tf}}}=\frac{ \overrightarrow{i_{NED_{tf}}}\times\overrightarrow{j_{NED_{tf}}}}{\left\| \overrightarrow{i_{B_{fl}}}\times\overrightarrow{j_{NED_{tf}}}\right\|} \tag{13}\]  
\[\overrightarrow{i_{B_{tf}}}=\frac{\overrightarrow{ LOS_{B}}}{\left\|\overrightarrow{ LOS_{B}}\right\|},\ \ \overrightarrow{j_{B_{tf}}}=\frac{ \overrightarrow{ LOS_{B}}\times\overrightarrow{s_{R}}}{\left\|\overrightarrow{ LOS_{B}}\times\overrightarrow{s_{R}}\right\|},\ \ \ \overrightarrow{k_{B_{tf}}}=\frac{ \overrightarrow{i_{B_{tf}}}\times\overrightarrow{j_{B_{tf}}}}{\left\| \overrightarrow{i_{B_{tf}}}\times\overrightarrow{j_{B_{tf}}}\right\|} \tag{14}\]  
Note that to determine the attitude of a vehicle with respect to a reference frame, the direction cosine matrix (DCM) must be determined. It represents the attitude of the body frame (B) relative to the reference frame (NED). It is specified by a 3 \(\times\) 3 rotation matrix, where the columns represent unit vectors in the body axes projected along the reference axes. Therefore, the expression to determine the DCM is as shown in Equation (15), where \(\left[\overrightarrow{i_{B_{i}}},\overrightarrow{j_{B_{i}}},\overrightarrow {k_{B_{i}}}\right]\) is a \(3\times 3\) square matrix composed of orthonormal vectors in body triad, \(\left[\overrightarrow{i_{NED_{i}}},\overrightarrow{j_{NED_{i}}},\overrightarrow {k_{NED_{i}}}\right]\) expresses the same concept in NED triad, and \(DCM_{B,NED_{i}}\) is the director cosine matrix that transforms NED triad into body triad. Notice that depending on the phase of flight, i.e., intermediate (\(fl\)) or terminal (\(tf\)), the matrix may be calculated with different inputs.