## 2 Materials and Methods
### Development of UAV Photogrammetry Simulator for 3D Modeling
#### 2.1.4 Automatic Path Planning for Flight  
The simulator automatically creates a path to fulfill output qualities such as GSD, forward overlap, side overlap, and camera tilt with respect to focal length, sensor size, and image size. Figure 3 illustrates the process of automatic path planning and the parameters used in nadir and oblique photography. The path planning process comprises creating a convex polygon, determining the distance from the object, determining the course, and determining the shooting waypoints. The path design requires the following inputs: Object model, GSD, focal length, sensor size, image size, forward overlap, side overlap, and camera tilt.  
In the creating a convex polygon step, the built polygon is made convex by filling the concave part of the 3D model. UAVs find it difficult to access the concave parts, and a risk of accidents exists. Thus, the polygon is converted to convex to prevent accidents in real flight.  
Figure 2: Architecture and modules of the simulator.  
Figure 4a illustrates the flight path in nadir photography; the nadir path follows the zigzag shape on a plane with a certain distance \(D\) from the top of the object. Figure 4b,c demonstrate the oblique path that has a buffer distance \(D\) from the convex polygon of the object while moving floor by floor. For both nadir and oblique photography, \(D_{m}\) is the distance between the photo-taking points within the same strip, and \(D_{s}\) is the distance between the strips.  
The distance between the object and UAV is calculated to determine the distance from the object step using focal length, sensor size, and image size. The distance \(D\) is given by Equation (1), where \(s\) is the length of the sensor, \(G\) is the GSD,\(f\) is the focal length, and \(p\) is the number of pixels.  
\[D=\frac{G\cdot f\cdot p}{s} \tag{1}\]  
In the course setting stage, the interval between two consecutive strips is determined. The strip direction in nadir photography is the same as the UAV's yaw direction. Therefore, the \(x\)-axis component of the camera, the width of the sensor (\(s_{w}\)), the focal length in the \(x\) direction (\(f_{x}\)), the distance (\(D\)) from the object, and the side overlap (\(a_{s}\)) are used. The distance (\(D_{s}\)) between strips in the nadir is given by Equation (2).  
\[Ds=D\frac{s_{w}}{f_{x}}(1-a_{s}) \tag{2}\]  
In oblique photography, the strip direction is perpendicular to the UAV's yaw direction. Thus, the \(y\)-axis component of the camera, the height of the sensor (\(s_{h}\)), the focal length in the \(y\) direction (\(f_{y}\)), the distance (\(D\)) from the object, and the side overlap (\(a_{s}\)) are used. The distance (\(D_{s}\)) between strips in the object is given by Equation (3).  
\[Ds=D\frac{s_{h}}{f_{y}}(1-a_{s}) \tag{3}\]  
Figure 3: Overall process of automatic path planning in the simulator.  
If visual line of sight (VLOS) flight should be applied, the minimum height (\(H_{\text{s}}\)) from the land surface can be set to secure the sight. In this case, the minimum height (\(H_{\text{s}}\)) can be higher than the object height.  
In the waypoints stage, the waypoint is determined within the strip according to the set forward overlap, which is perpendicular to the side overlap. The UAV takes images according to the set interval (\(D_{m}\)) along the strip. In nadir photography, the height of the sensor (\(s_{h}\)), the focal length in the y direction (\(f_{y}\)), the distance (\(D\)) from the object, and the forward overlap (\(a_{f}\)) are used to determine the interval (\(D_{m}\)) between waypoints along the strip, as given by Equation (4).  
\[D_{m}=D\frac{S_{h}}{f_{y}}\Big{(}1-a_{f}\Big{)} \tag{4}\]  
Similarly, in oblique photography, the width of the sensor (\(s_{w}\)), the focal length in the x direction (\(f_{x}\)), the distance (\(D\)) from the object, and the forward overlap (\(a_{f}\)) are used to determine the interval (\(D_{m}\)) between waypoints along the strip, as given by Equation (5).  
\[D_{m}=D\frac{S_{w}}{f_{x}}\Big{(}1-a_{f}\Big{)} \tag{5}\]