## 2 Relative Motion Dynamics Model
### Formation Dynamics Modeling  
As illustrated in Figure 1, the system under consideration consists of two satellites: SatA and SatB. The formation's mass center's coordinates in ECI coordinates are denoted as \(\mathbf{Q}_{0}=[X_{0},Y_{0},Z_{0}]^{\mathrm{T}}\). The projection of this vector in the Hill frame is expressed as \(\mathbf{q}_{0}=[q_{0},0,0]^{\mathrm{T}}\). The coordinates of SatA are defined as \(\mathbf{Q}_{a}=[X_{a},Y_{a},Z_{a}]^{\mathrm{T}}\). In the context of formation flight, particular attention is paid to the relative positions of the satellites within the Hill coordinate frame. The vector describing the position of SatA relative to the formation's mass center is denoted by \(\mathbf{q}_{a}=[x_{a},y_{a},z_{a}]^{\mathrm{T}}\). Likewise, the position vector for SatB is denoted as \(\mathbf{q}_{b}=[x_{b},y_{b},z_{b}]^{\mathrm{T}}\). The dynamics pertaining to these relative positions will be explored further in this discussion. Figure 1: Geometry of the coordinate frames. According to the defined parameters of the formation mass center, the relative position vectors \(\mathbf{q}_{a}\) and \(\mathbf{q}_{b}\) comply with the following relationship:  
\[m_{a}\mathbf{q}_{a}+m_{b}\mathbf{q}_{b}=\mathbf{0} \tag{4}\]  
In the formula, \(m_{a}\) and \(m_{b}\) represent the masses of satellites A and B, respectively. Thus, we can define \(k=\frac{m_{a}}{m_{b}}\). Assuming that electromagnetic formation flying is propellant-free, the mass of the satellites can be treated as a constant. Consequently, it follows that  
\[m_{a}\dot{\mathbf{q}}_{a}+m_{b}\dot{\mathbf{q}}_{b}=\mathbf{0} \tag{5}\]  
Consider SatA, whose kinetic energy \(\mathcal{T}\) can be expressed as  
\[\mathcal{T}\big{(}\dot{\mathbf{Q}}_{a}\big{)}=\frac{1}{2}m_{a}\big{\|}\dot{\mathbf{Q}}_ {a}\big{\|}^{2} \tag{6}\]  
The potential energy of SatA encompasses two components: gravitational potential energy \(\mathcal{U}_{g}\) and electromagnetic potential energy \(\mathcal{U}_{e}\). The gravitational potential energy, subject to \(J_{2}\) perturbations, is formulaable in the following manner. \[\mathcal{U}_{g}(\mathbf{Q}_{a})=-\frac{\mu m_{a}}{R_{a}}\bigg{[}1-\frac{J_{2}}{2} \frac{R_{e}^{2}}{R_{a}^{2}}\bigg{(}3\frac{Z_{a}^{2}}{R_{a}^{2}}-1\bigg{)} \bigg{]} \tag{7}\]  
where \(R_{a}\) is the distance between SatA and the Earth's center, \(\mu\), \(R_{e}\), and \(J_{2}\) are the gravitational constant, the Earth's radius, and the second zonal gravitational coefficient, respectively. By conceptualizing the electromagnetic coils on each satellite as a maneuverable magnetic dipole, the magnetic field attributed to SatB can be delineated as  
\[B_{b}(\mathbf{\rho})=\frac{\mu_{0}}{4\pi}\bigg{(}\frac{3\mathbf{\mu}_{b}^{\text{T}}\bm {\rho}}{\|\mathbf{\rho}\|^{5}}\mathbf{\rho}-\frac{\mathbf{\mu}_{b}}{\|\mathbf{\rho}\|^{3}} \bigg{)} \tag{8}\]  
where \(\mathbf{\mu}_{b}\) represents the magnetic dipole vector on SatB, \(\mathbf{\rho}\) is the vector from SatB to SatA, and \(\mu_{0}=4\pi\times 10^{-7}\)\(\mathrm{N/A^{2}}\) is the permeability of free space. The electromagnetic potential energy of the formation is given by [7]  
\[\mathcal{U}_{e}=-\mathbf{\mu}_{a}^{\text{T}}B_{b}(\mathbf{\rho}) \tag{9}\]  
Subsequently, the Lagrangian function is formulable as follows:  
\[\mathcal{L}=\mathcal{T}-\mathcal{U}_{g}-\mathcal{U}_{e} \tag{10}\]  
To articulate the dynamics of spacecraft within the Hill frame, it is imperative to execute specific coordinate transformations between the Hill and ECI frames. The transformation from the Hill frame to the ECI frame is stipulated by the subsequent equation. \[\mathbf{T}= \begin{bmatrix}c_{\Omega}c_{\theta}-s_{\Omega}s_{\theta}c_{i}&-c_{ \Omega}s_{\theta}-s_{\Omega}c_{\theta}c_{i}&s_{\Omega}s_{i}\\ s_{\Omega}c_{\theta}+c_{\Omega}s_{\theta}c_{i}&-s_{\Omega}s_{\theta}+c_{\Omega }c_{\theta}c_{i}&-c_{\Omega}s_{i}\\ s_{\theta}s_{i}&c_{\theta}s_{i}&c_{i}\end{bmatrix} = \begin{bmatrix}\mathbf{T}_{1} \\ \mathbf{T}_{2}\\ \mathbf{T}_{3}\end{bmatrix}