## 3 Formation Methods and Simulation  
Based on the work above, this chapter elaborates the distributed formation method based on the 3 \(\times\) 3 magic square and the chain rules of visual reference. Using the method, the advantages of the VM and its improved models are integrated into the large-scale UAV cluster formation, so that the VM's redundant neighborhood information can be avoided  
Figure 6: 8 Basic directions: (**a**) Schematic diagram of the eight directional positions of the UAV in initial formation; (**b**) Schematic diagram of the eight directional positions of the UAV after turning. Figure 7: Distribution of the cooperative signal lamps located on the UAV surface in different directions. in its formation. Notably, this method is characterized by a more stable neighborhood information collection than the RLosVM model and the memory function of the FOVM model. In addition, the dynamic visual reference in the FNN model has been improved to enhance the formation's anti-jamming and anti-deception capacity. First, the formation was divided into two areas, kept at a certain distance to be anti-jamming. One was the unformatted UAV area, and the other was the formatted area. The involved UAVs could fly freely in the first area and at a random position outside the formatted area. When entering the formatted area, UAVs have their designated routes until arriving at the terminal. However, the routes of all UAVs were constrained by the grid formation, in which each UAV in flight maintained a certain distance, the same altitude and the same speed between them, using airborne distance sensors and their vision system. Based on the 3 \(\times\) 3 magic square and the chain rules of visual reference, the vision system determines which drones in which directional positions can be referenced to guide the formation. Distributed Formation Method Based on the 3 \(\times\) 3 Magic Square and the Chain Rules of Visual Reference  
For the formatted areas, a suppositional 3 \(\times\) 3 magic square grid was set. The size of the square varied according to the scale of formation. Each square was marked with a number to show its position. For instance, Figure 8 is a typical 3 \(\times\) 3 magic square diagram. When the first UAV entered the formatted area, the very place it arrived was the square numbered 5, as shown in Figure 9. Afterward, the second UAV flew from the unformatted area to the square numbered 1. As mentioned above, the visual sensor of each UAV could sense 8 basic directions in the same plane (Figure 6). Thus, the eight directions of UAVs in grids 5 and 1 are shown in Figure 10.  
According to Figures 9 and 10, the UAV in square 1 was in direction 8 of the UAV in square 5, whose airborne visual sensor identified the cooperation signal of the UAV in square 1. Thus, the poses of the UAV in square 1 could be obtained. The UAV in square 1  
Figure 8: 3 \(\times\) 3 magic square formation code. Figure 10: Eight directions of UAVs in square 5 and square 1. Figure 9: 3 \(\times\) 3 magic square formation. could offer reference to that in square 5 in direction 8. Similarly, the UAV in square 5 was in direction 4 of the UAV in square 1, whose airborne visual sensor identified the cooperation signal of the UAV in square 5. Therefore, the poses of the UAV in square 5 could be obtained. The UAV in square 5 was set as the reference for the UAV in square 1 in its direction 4. Similarly, through this visual cross-reference, UAVs could be formatted in other parts of the 3 \(\times\) 3 magic square. After the formation, a visual reference topological structure diagram of the 3 \(\times\) 3 magic square was formed, as shown in Figure 11, where node numbers of the square referred to individual UAVs, and the lines between nodes showed the visual reference among UAVs. According to the 3 \(\times\) 3 magic square agreement and chain rules of visual reference, UAVs to be referred must meet two prerequisites. First, the numbers of UAVs and their reference must be in the same line in the topological structure diagram.