## 4 Proposed Distributed Trajectory Planner Based on PSO and Bresenham Algorithm
### Bresenham Algorithm  
B [PERSON]'s line algorithm is a line drawing algorithm to form a close approximation to a straight line between two points by determining the points of an n-dimensional raster. This algorithm is named after [PERSON] who developed it in 1962 at IBM [38]. This algorithm is a well-known earliest developed algorithm in the field of computer graphics. It is used for scan converting a line and involves only sixteenth integer addition, subtractions, and multiplication operations. The original algorithm extension can be used for drawing circles. In this method, the next point selected is the one that has the least distance from the true line. It can be also called an incremental error algorithm [39]. Some other algorithms are also frequently used in modern computer graphics because they can support antialasing. Since this algorithm has been used for drawing a line from one particular point to another, we used this technique to ensure we conducted surveillance for the whole operational area. When this algorithm draws a line from one point to another point, it marks up the pixel or points between those two points. Similarly, in our implementation, when monitoring drones surveille from one waypoint to another waypoint (waypoints of best-paths which are generated through PSO algorithm), it made the cell SAI value zero to the corresponding cell SAI values. By making the cell SAI value to zero, we ensured that those cells have been visited by the monitoring drones. Therefore, in the next flight time, monitoring drones were not required to surveille those cells as there was a focus on surveilling the remaining cells. Therefore, we ensured the whole surveillance of the operational area and avoided the repetition of previously surveilled cells.  
The working procedure of the Bresenham Algorithm can be described as follows. Once a point is chosen at any step, the next point is,  
* Either the one to its right (lower-bound for the line)
* On top, it is right and up (upper-bound for the line).  
[PERSON]'s algorithm is used to implement the construction of a straight-line trajectory [40]. Assuming the initial position is \((x_{1},y_{1})\), the direction to follow is the endpoint \((x_{end},y_{end})\), which is given by the straight line. The objective of the algorithm is to construct a straight line approximately by deriving the sequence of positions in the grid. This is achieved by moving at each step to the next position along the \(x\)-axis (i.e., from \(x_{i}\) to \(x_{i+1}\)) and then by selecting \(y_{i}\) or \(y_{i+1}\) which is the closest coordinate to the line. The points in the grid are indicated as \((x_{i},y_{i})\) where \(i\) is used for index labeling the points in the grid. Thus, the \(y\) coordinate value at each step in the grid is chosen. While a decision parameter \(p_{i}\) is chosen, the calculation is done for each time step.  
The algorithm is described as follows:  
* Start from the two-line, starting point \((x_{1},y_{1})\) and endpoint \((x_{end},y_{end})\) and then calculate the constants where \(\Delta x=(x_{end}-x_{1})\) and \(\Delta y=(y_{end}-y_{1})\).
* Calculate the first value of the decision parameter by using the equation: \[p_{0}=2\Delta y-\Delta x.\] (28)
* For each value of \(x_{i}\) along the line, check the following condition, if \(p_{i}<0\), the next point needs to be selected as \((x_{i+1},y_{i})\) and: \[p_{i+1}=p_{i}+2\Delta y.\] (29)
* Otherwise, the next point to be selected is \((x_{i+1},y_{i+1})\) and: \[p_{i+1}=p_{i}+2\Delta y-2\Delta x.\] (30)  
Repeat the steps until the set destination i.e., \((x_{end},y_{end})\) is reached  
The pseudocode of the Bresenham algorithm is given in Algorithm 2: