# Collision Avoidance Behavior Mining Model Considering Encounter Scenarios
## 2 Methodology
### Ship Collision Avoidance Behavior Recognition
#### 2.2.2 Curvature-Based Ship Collision Avoidance Behavior Recognition  
To address the issues in behavior recognition based on ship AIS data, this paper proposes a curvature-based ship collision avoidance turning point recognition algorithm. By calculating the curvature of discrete ship trajectory points and combining actual ship navigation characteristics, the algorithm determines whether the curvature change at a trajectory point corresponds to a ship's turning behavior, thus filtering out interference from wind, waves, and currents. Furthermore, by identifying the presence of re-navigation behavior, the algorithm determines whether the turning point is a collision avoidance maneuver, enabling the extraction of ship collision avoidance behaviors. (1) Ship Trajectory Curvature Calculation Method  
Because the trajectory formed by ship AIS data is discrete, this paper uses the curvature of the quadratic curve determined by three adjacent points as the trajectory curvature at the central point. The point to be calculated is referred to as the central point, with the points before and after it referred to as the Fore and Aft points, respectively, as shown in Figure 4.  
Let the coordinates of the central point to be calculated be \(P_{i}(x_{i},y_{i})(i>1)\). Take the Fore point \(P_{i-1}(x_{i-1},y_{i-1})\) and the Aft point \(P_{i+1}(x_{i+1},y_{i+1})\) to perform quadratic curve fitting. For each trajectory point, establish a parametric equation, where \(\delta\) is the parameter of the fitted quadratic curve, as shown in Equation (5):  
\[\left\{ \begin{array}{l}x_{i}=a_{i-1}+a_{i}\delta+a_{i+1}\delta^{2}\\ y_{i}=b_{i-1}+b_{i}\delta+b_{i+1}\delta^{2}\end{array} \right. \tag{5}\]  
Here, \(i\) serves a dual purpose. Firstly, it is used for iterative processing of trajectory data points in the algorithm. Secondly, it is associated with a specific time sample, representing the i-th ship trajectory point \(P_{i}(x_{i},y_{i})\)'s position information, including longitude, which is \(x_{i}\), latitude, which is \(y_{i}\), and the timestamp at this moment, which is \(t_{i}\). Figure 4: Schematic diagram of trajectory curvature calculation. The range of values is determined using the lengths of two vectors, where \(\delta_{a}\) represents the vector length between the central point and the Fore point and \(\delta_{b}\) represents the vector length between the central point and the Aft point, as shown in Equation (6):  
\[\left\{ \begin{array}{l}\delta_{a}=\sqrt{\left(x_{i}-x_{i-1}\right)^{2}+\left(y _{i}-y_{i-1}\right)^{2}}\\ \delta_{b}=\sqrt{\left(x_{i+1}-x_{i}\right)^{2}+\left(y_{i+1}-y_{i}\right)^{2} }\end{array} \right. \tag{6}\]  
The parameter \(\delta\) satisfies \(\left(x,y\right)|_{\delta=-\delta_{a}}=\left(x_{i-1},y_{i-1}\right)\), \(\left(x,y\right)|_{\delta=0}=\left(x_{i},y_{i}\right)\), \(\left(x,y\right)|_{\delta=\delta_{b}}=\left(x_{i+1},y_{i+1}\right)\). Based on the above three conditions, establish the matrices \(X=MA\) and \(Y=MB\), and then solve the linear equations using matrix inversion. The specific matrices are shown in Equations (7) and (8), as follows:  
\[ \begin{pmatrix}x_{i-1}\\ x_{i}\\ x_{i+1}\end{pmatrix} = \begin{pmatrix}1&-\delta_{a}&\delta_{a}^{2}\\ 1&0&0\\ 1&\delta_{b}&\delta_{b}^{2}\end{pmatrix}\begin{pmatrix}a_{i-1}\\ a_{i}\\ a_{i+1}\end{pmatrix}  \tag{7}\]  
\[ \begin{pmatrix}y_{i-1}\\ y_{i}\\ y_{i+1}\end{pmatrix} = \begin{pmatrix}1&-\delta_{a}&\delta_{a}^{2}\\ 1&0&0\\ 1&\delta_{b}&\delta_{b}^{2}\end{pmatrix}\begin{pmatrix}b_{i-1}\\ b_{i}\\ b_{i+1}\end{pmatrix}  \tag{8}\]  
By solving for the quadratic curve coefficients \(\left(a_{i-1},a_{i},a_{i+1}\right)\) and \(\left(b_{i-1},b_{i},b_{i+1}\right)\), the parametric equation of the curve is obtained. The derivatives of the variables \(\left(x^{\prime},x^{\prime\prime},y^{\prime},y^{\prime\prime}\right)\) can then be calculated, as shown in Equation (9):  
\[\left\{