# Effect of Formation Size on Flocking Formation Performance for the Goal Reach Problem
## 2 Materials and Methods
### Sensing Power  
In nature, members of a flock usually know where they are heading, even if they do not precisely know their goal location. Therefore, we propose the sensing power, which acts as the effect of such knowledge on the flock's heading direction, and which is added to the flock controller. This sensing power allows the flock to take off better and gives the controller a more natural flock characteristic. Moreover, it helps lost or late agents to integrate the flock quickly by assisting them to orient themselves towards the center of mass of the flock. Indeed, an agent, in their way with the flock, can encounter several obstacles. By avoiding these obstacles, they can move away from the flock and lose the flock heading direction; thus, they have to rely on their senses. In this case, the sensing power is triggered to direct the agent towards the flock. Based on the limitations of the simulation arena's size, we decided to apply this sensing power only in the initial period, such that it does not cause guided flocking behavior.  
The sensing power is represented by a vector comprising two angles of direction illustrating the fields of attraction of the objective. The objective is a circle with center, \(C\), and radius, \(r\). This circle may represent either the target zone or the flock. Figure 2 depicts the principle of the attraction field of the sensing power.  
Let us consider that an agent is in position, \(P_{0}\). The attraction field of the objective is then delimited by \(P_{0}\) and two points of tangency (\(P_{1},P_{2}\) say) in the circle (i.e., the objective)--where (\(P_{0}\), \(P_{1}\)) defines a first line that is tangent to the circle and (\(P_{0}\), \(P_{2}\)) defines a second line that is also tangential to the circle. The agent has the freedom to move inside this field of attraction. Let us denote:  
* \(\theta=\measuredangle(P_{2}P_{0}P_{1})\): the angle in \(P_{0}\), defined by the triplet (\(P_{2},P_{0},P_{1}\)) (Equation (3)), \[\theta=2\times\tan^{-1}(\frac{r}{\sqrt{d^{2}-r^{2}}})\] (3)
* \(\phi=\measuredangle((P_{0},C),X-axis)\): the angle in \(P_{0}\), defined by the two lines (\(P_{0},C\)) and \(X-axis\) (Equation (4)), \[\phi=\arctan 2(C_{y}-P_{0y},C_{x}-P_{0x})\] (4)
* \(d=\lVert\overrightarrow{P_{0}C}\rVert\) the Euclidean distance between \(P_{0}\), the location of the agent, and \(C\), the center of the objective. One can notice that the agent may choose randomly a direction angle, \(\theta_{rand}\), so that \(\theta_{rand}\in[\phi-\theta/2,\phi+\theta/2]\) (Equation (5)).  
\[\theta_{rand}=random(\phi-\theta/2,\phi+\theta/2) \tag{5}\]  
The sensing power is represented as vector of two direction angles \(sp_{i}=[\phi,\theta]^{T}\), where their combination characterizes the opening angle of the field of attraction sector (blue sector in Figure 2). Applying this sensing power with a random angle accordingly allows the agent to proceed towards their objective (Equation (6)).  
\[s\hat{p}_{i}=\begin{cases}\theta_{rand},&\text{if the sensing power is triggered}\\ 0,&\text{otherwise}\end{cases} \tag{6}\]