# Camera Path Generation for Triangular Mesh Using Toroidal Patches
## 3 Camera Path Generation  
### Preprocessing  
The triangular mesh used for camera path generation can be sourced from 3D modeling software or acquired via 3D scanning. During the 3D scanning process, vertex data may contain noise, which can complicate the calculation of precise curvature. This imprecision can subsequently adversely affect the quality of curvature-based camera path optimization. To mitigate such issues, a mesh smoothing technique is employed in the preprocessing stage [23]. This step is crucial in minimizing the impact of scanning-induced noise and maintaining the integrity of the curvature-based camera path generation process. After smoothing, we estimate the Gaussian curvature at each vertex using the surface-fitting method [15], which is the basis of constructing a toroidal patch-based spatial data structure [16]. This structure offers a refined mesh approximation and incorporates the computed curvature data. Each toroidal patch begins at a specific vertex of the smoothed mesh, using the curvature information to initiate the process. The patch then expands its domain by comparing distances to adjacent triangles. The expansion must adhere to a predefined tolerance value, the maximum allowable distance between the set of bounding faces and the toroidal patch itself. If a face is not included in any other toroidal patches, we generate a toroidal patch for that face using one of its vertices. However, sometimes this process generates toroidal patches that do not meet the tolerance. To ensure accuracy, we exclude inaccurate patches after generating toroidal patches. In an area characterized by minimal variations in curvature, a toroidal patch expands to approximate multiple adjacent triangles within a single patch. This expansion is driven by extending the domain of the toroidal patch, covering from the reference vertex to the vertices of its adjacent triangles, all within the predetermined tolerance. Conversely, in an area with pronounced changes in curvature, which implies a visually distinct or robust appearance, the toroidal patch tends to be smaller. Therefore, a region with a high concentration of toroidal patches indicates distinct geometric attributes. We can determine the camera path by using the number of patches as a weighting factor. Without directly employing the toroidal patches, we initially enclose the mesh within a bounding cylinder, subdivide it into uniform segments, and assign the number of toroidal patches to each segment as the weight for the camera path. The lateral surface of the bounding cylinder is denoted as \(C_{h,r}(u,v)\), where \(u,v\in[0,1]\times[0,2\pi]\). This surface is the foundation for storing the weights for camera path determination. In this formulation, \(h\) represents the height of the cylinder, while \(r\) stands for its radius. The generated \(C_{h,r}(u,v)\) is uniformly divided by \(m\) in the \(u\) direction and \(n\) in the \(v\) direction, creating grids to allocate \(m\times n\) weights. Figure 2 displays the results of equal partitioning of bounding cylinders for ten triangular mesh models. To allocate the weight with the toroidal patches to the uniform grids of \(C_{h,r}(u,v)\), we orthogonally project the centroid of each face (triangle) onto \(C_{h,r}(u,v)\). This projection involves computing the direction vector \(\overrightarrow{D}\) that originates from a point on the axis of \(C_{h,r}(u,v)\) and shares the same height as the face's centroid, pointing towards \(C_{h,r}(u,v)\) (i.e., \(\overrightarrow{D}\) passes by the face's centroid and a point on \(C_{h,r}(u,v)\)). The centroid is then offset by \(r\) in the direction of \(\overrightarrow{D}\), and the resulting projected vertex is mapped to its corresponding grid. After mapping all faces to the grid, each grid's weight is determined by averaging the number of toroidal patches associated with faces within a two-ring neighborhood. We employ a two-ring neighborhood because, in certain instances, the smoothing process may not completely remove unintended cusps at vertices.