## 2 Model of Ship Photovoltaic Panel Swing Motion  
Here, the solar photovoltaic modules are all horizontally arranged on the ship deck, and the photovoltaic modules on the ship will move together with the ship's swing. While sailing in the ocean, due to the effects of wind, waves, and ocean currents, this will produce six degrees of freedom (DOF) movements, namely, surge, sway, heave, roll, pitch, and yaw [17]. This section introduces the calculation model of the spatial motion variation of shipborne photovoltaic panels under the influence of rolling and pitching when the ship is sailing.  
The three-dimensional coordinate transformation model in space takes the common transformation between the world and the camera coordinate system as an example. In the rotation matrix of the hull, the Euler angle is rotated by rotating the rigid body around the axis of the origin [18]. As shown in Figure 1, blue coordinates is the starting system \((x,y,z)\), the red is the coordinate system after rotation \((x^{\prime},y^{\prime},z^{\prime})\). Taking a vector \(\overset{\rightarrow}{OP}\) in a three-dim coordinate system to rotate around the \(z\) axis by the angle of \(\theta\) as an example to derive the process of converting the Euler angle of rotation from the world coordinate system to the camera coordinate system, as shown in Figure 2.  
Figure 1: Rotation matrix of a three-dimensional space coordinate system.  
In Figure 1(a), \(OP\) forms \(P^{\prime}\) as a projection on the xOy plane, rotating around the Z axis, equivalent to \(OP^{\prime}\)s projection on the xOy plane, which rotates around the origin. As shown in Figure 1(b), \(OP^{\prime}1\) rotates \(\alpha\) degrees to \(OP^{\prime}2\) and \(OP^{\prime}1=OP^{\prime}2\)[13].  
\[\left\{\begin{array}{l}P^{\prime}1=(x1,y1)\\ P^{\prime}2=(x2,y2)\end{array}\right.\left\{\begin{array}{l}x1=OP^{\prime}1 \cos\psi\\ y1=OP^{\prime}1\sin\psi\end{array}\right. \tag{1}\]  
It can be obtained that the rotation matrix of \(\beta\) angle rotation around the \(Z\) axis is  
\[R_{Z}(\beta)=\left[\begin{array}{ccc}\cos\beta&-\sin\beta&0\\ \sin\beta&\cos\beta&0\\ 0&0&1\end{array}\right] \tag{2}\]  
The rotation from the world coordinate changed to the camera coordinate shows that the rotation angle around the Z axis is yaw, where then the rotation angle twirls around the Y axis of the coordinate system after rotation, and then the roll angle is rotated around the X axis of the coordinate system after rotation, where \(\beta=\text{roll},\gamma=\text{pitch},\alpha=\text{heave}\), therefore the final rotation angle matrix is as given follows:  
\[R_{z}R_{y}R_{x}=\left[\begin{array}{cccc}\cos(\alpha)&-\sin( \alpha)&0\\ \sin(\alpha)&\cos(\alpha)&0\\ 0&0&1\end{array}\right]\begin{array}{cccc}\cos(\gamma)&0&\sin(\gamma)\\ 0&1&0\\ -\sin(\gamma)&0&\cos(\gamma)\end{array}\right]\begin{array}{cccc}1&0&0\\ 0&\cos(\beta)&-\sin(\beta)\\ 0&\sin(\beta)&\cos(\beta)\end{array} \tag{3}\] \[=\left[\begin{array}{cccc}\cos(\alpha)\cos(\gamma)&\cos( \alpha)\sin(\gamma)\sin(\beta)-\sin(\alpha)\cos(\beta)&\cos(\alpha)\sin(\gamma) \cos(\beta)+\sin(\alpha)\sin(\beta)\\ \sin(\alpha)\cos(\gamma)&\sin(\alpha)\sin(\gamma)\sin(\beta)+\cos(\alpha) \cos(\beta)&\sin(\alpha)\sin(\gamma)\cos(\beta)-\cos(\alpha)\sin(\beta)\\ -\sin(\gamma)&\cos(\gamma)\sin(\beta)&\cos(\gamma)\cos(\beta)\end{array}\right]\]  
Next, one needs to calculate the angle \(\delta\) change between the photovoltaic panel and the sea level after generating roll angle \(R_{X}\) and pitch angle \(R_{Y}\). According to the Equations (3) and (4), we can get \(\delta\):  
\[\delta=\text{a }\tan\,2(r32,r33) \tag{4}\] \[=\text{arc }\tan(\frac{\cos(\gamma)\sin(\beta)}{\cos(\gamma)\cos( \beta)})\quad-\pi<\delta<\pi\]  
The numerical values of the roll and pitch will be forecasted by the proposed algorithm in the next section.