# Three-Dimensional Obstacle Avoidance Strategy for Fixed-Wing UAVs Based on Quaternion Method
## 2 Problem Formulation  
### Notation  
Matrices are in capital \(\mathbf{M}\), vectors are in bold \(\mathbf{x}\), sets are in mathcal \(\mathcal{H}\), and the Minkowski sum of two sets is expressed as \(\mathcal{H}\oplus\mathcal{F}\). The Euclidean norm of vector \(\mathbf{x}\) is expressed as \(\|\mathbf{x}\|\). The superscript indicates the coordinate, and the coordinate systems involved in this article include the inertial coordinate system [26], \(n\); body coordinate system, \(b\); velocity coordinate system, \(s\); error coordinate, \(e\); avoidance coordinate system, \(a\); and desired coordinate system, \(d\). The conversion between coordinate systems commonly relies on rotation matrixes or quaternions. A velocity vector \(\mathbf{v}\) in \(b\)-frame \(\mathbf{v}^{b}=\left[ \begin{array}{cccc}v_{\mathbf{x}}^{b}&v_{y}^{b}&v_{z}^{b}\\ \end{array} \right]^{\mathrm{T}}\in\mathbb{R}^{3}\) coincides with the \(x\)-axis of the \(s\)-frame. Then, the velocity vector \(\mathbf{v}\) in the \(s\)-frame is expressed as \(\mathbf{v}^{s}=\left[ \begin{array}{cccc}\|\mathbf{v}^{b}\|&0&0\end{array} \right]^{ \mathrm{T}}=\mathbf{R}_{b}^{s}\mathbf{v}^{b}\), where the rotation matrix  
\[\mathbf{R}_{b}^{s}\in SO^{3}=\left\{\mathbf{R}\in\mathbb{R}^{3}:\mathbf{R}^{\mathrm{T}}\bm {R}=\mathbf{I},\ \det(\mathbf{R})=1\right\}\]  
(\(\mathbf{I}\) is an identity matrix) represents the rotation from frame-\(b\) to frame-\(s\). The quaternion is represented by a column matrix:  
\[\mathbf{q}_{sb}=\left[ \begin{array}{cccc}q_{0}&q_{1}&q_{2}&q_{3}\end{array}  \right]^{\mathrm{T}}=\left[ \begin{array}{cccc}\eta_{sb}&\epsilon_{sb}^{ \mathrm{T}}\end{array} \right]^{\mathrm{T}}=\left[ \begin{array}{cccc}\cos( \frac{\theta_{sb}}{2})&\mathbf{k}_{sb}^{\mathrm{T}}\sin(\frac{\theta_{sb}}{2}) \end{array} \right]^{\mathrm{T}}\]  
where \(\eta_{sb}\) is a scalar, \(\epsilon_{sb}\in\mathbb{R}^{3}\) is a vector, \(\theta_{sb}=\cos^{-1}\left(\frac{v^{b}-v^{b}}{\|\mathbf{v}^{a}\|^{2}}\right)\) represents the rotation angle, and \(\mathbf{k}_{sb}\in\mathbb{R}^{3}=\frac{v^{b}\times\mathbf{v}^{s}}{\|\mathbf{v}^{b}\times \mathbf{v}^{b}\|}\) represents the rotation axis. The quaternion and the rotation matrix can be transformed through the equation:  
\[\mathbf{R}_{b}^{s}=I+2\eta_{sb}S(\epsilon_{sb})+2S^{2}(\epsilon_{sb}),\ S(\mathbf{v})= \left[ \begin{array}{cccc}0&-v_{3}&v_{2}\\ v_{3}&0&-v_{1}\\ -v_{2}&v_{1}&0\end{array} \right] \tag{1}\]  
Taking the derivative of the rotation matrix, we get \(\hat{\mathbf{R}}_{b}^{s}=\mathbf{R}_{b}^{s}S\left(\mathbf{w}_{sb}^{b}\right)\), where is the projection of the rotation of vector \(\mathbf{b}\) relative to vector \(\mathbf{c}\) on \(\mathbf{b}\). Quaternion multiplication can deal with the problem of combing finite time rotations of the rigid body. Supposing there are two consecutive rotation quaternions, then they can be combined into an equivalent quaternion through quaternion multiplication: \(\mathbf{q}\otimes\mathbf{p}=\mathbf{M}(\mathbf{q})\mathbf{p}\), where \(\mathbf{M}(\cdot)\) is the quaternion multiplication operator: \(\mathbf{M}(\mathbf{q})=\left[ \begin{array}{cccc}q_{0}&-q_{1}&-q_{2}&-q_{3}\\ q_{1}&q_{0}&q_{3}&-q_{2}\\ q_{2}&-q_{3}&q_{0}&q_{1}\\ q_{3}&q_{2}&-q_{1}&q_{0}\end{array} \right]\). **Theorem 1**. : **([27]). ** _If a rigid body makes a finite number of consecutive rotations around the axes that pass the same fixed point, then the size of the composite rotation angle has nothing to do with the order of each continuous rotation, but the direction of the composite rotation is related to the order of each continuous rotation._  
That is to say, the final attitude of the rigid body is related to the sequence of continuous rotation, and the position of the composite rotation axis changes with the sequence of continuous rotation. The rotation of the UAV between two coordinate systems can be disassembled into multiple continuous rotations: \(\mathbf{q}_{na}\)=\(\mathbf{q}_{ne}\otimes\mathbf{q}_{aa}\), where the formula represents the rotation from frame-\(a\) to frame-\(e\), and then to frame-\(n\).