# 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
\begin{array}{l}x^{\prime}=\frac{dx}{d\delta}|_{\delta=0}=a_{i}\\ x^{\prime\prime}=\frac{dx^{2}}{d\delta^{2}}|_{\delta=0}=2a_{i+1}\\ y^{\prime}=\frac{dy}{d\delta}|_{\delta=0}=b_{i}\\ y^{\prime\prime}=\frac{dy}{d\delta^{2}}|_{\delta=0}=2b_{i+1}\end{array} \right. \tag{9}\]  
The derivatives \(\left(x^{\prime},x^{\prime\prime},y^{\prime},y^{\prime\prime}\right)\) allow for the calculation of the curvature \(K\) at the central point, as shown in Equation (10):  
\[K=\frac{x^{\prime\prime}y^{\prime}-x^{\prime}y^{\prime\prime}}{\left(\left(x^{ \prime}\right)^{2}+\left(y^{\prime}\right)^{2}\right)^{3/2}}=\frac{2(a_{i+1}b _{i}-a_{i}b_{i+1})}{\left(a_{i}^{2}+b_{i}^{2}\right)^{3/2}} \tag{10}\]  
(2) Ship Collision Avoidance Turning Point Recognition  
The sliding window algorithm is commonly used to process linear and sequential datasets. By traversing the dataset with a window, it can better extract local data features in ship trajectory studies. Based on the ship trajectory point curvature calculation method established earlier, this paper adopts a combination of fixed and variable windows. The fixed window is used to calculate the discrete curvature of ship trajectory points and their correlations, marking the ship's turning points. The variable window is then used to determine whether the trajectory exhibits course recovery behavior, allowing for the identification of true collision avoidance turning points. A fixed-length window is used to identify ship turning points. Each time the window moves, the curvature of the trajectory points within the window is calculated, and a window filtering rule is defined to avoid distortion of ship trajectory data caused by wind, waves, currents, and data transmission errors. The trajectory data are evenly distributed, with a 20 s time interval. To ensure the stability of the initial window and the accuracy of curvature calculation during the sliding process, a window length \(L_{c}\) of three time points is used,with the window sliding one time point forward at each step, setting the sliding step size to 1. The sliding window algorithm is shown in Figure 5.  
Here, \(w_{j}\) represents the \(j\)-th window, \(t_{i}\) denotes the ship data at time \(i\), and \(P(t_{i})\) represents the ship's position at time \(t_{i}\), with coordinates \(P(lon(t_{i}),lat(t_{i}))\) and \(start_{j},\ end_{j}\) representing the start and end times of the \(w_{j}\) window, respectively. This paper establishes a window filtering rule by calculating the curvature of ship trajectory points. First, the ship trajectory data are arranged in chronological order and sequentially stored in the window. After the window data are fully received, the calculation of the initial window data begins. Using the curvature calculation method described earlier, the curvature \(C(t_{i})\) of the central trajectory point is computed using the latitude and longitude coordinate information of the three points within the window. According to the previous analysis of the characteristics of the ship's AIS trajectory, a ship in open water is generally moving in accordance with a fixed navigation plan, and the trajectory basically stays straight when going straight. This paper sets the curvature threshold \(C_{L}\) and the ship trajectory curvature of the point of the normal voyage \(C(t_{i})\) to maintain a small range of fluctuations in the range of 0 around the interval. If, during a meeting scenario with other ships, a ship needs to make collision avoidance maneuvers, COLREGs stipulate that avoidance of the ship must be timely and demonstrate obvious avoidance action. As such, the ship's trajectory curvature will be to the steering side of the larger degree of change, with the steering stage trajectory point curvature \(C(t_{i})\) > the curvature threshold \(C_{L}\).