# Camera Path Generation for Triangular Mesh Using Toroidal Patches
## 3 Camera Path Generation
### Preprocessing
This can lead to unexpectedly high curvature values, negatively influencing the subsequent camera path generation. Utilizing this broader neighborhood offers a more comprehensive context, effectively counterbalancing localized anomalies. Higher weights indicate a larger number of the toroidal patches are contained within the corresponding grid, while the lower weights imply a lower count of the toroidal patches. Since the camera path is generated along points with the highest weights along the lateral side of the cylinder, the path passes by areas including a larger number of toroidal patches. Algorithm 1 represents all this preprocessing step. ``` Input :\(M\)--an input triangular mesh; \(m,n\)--segment numbers of the \(M\)'s bounding cylinder Output :\(C_{h,r}\)--lateral surface of the cylinder \(M\leftarrow\text{Smoothing}(M)\) \(T\leftarrow\text{GenerateToroidalPatches}(M)\) \(C_{h,r}\leftarrow\text{GenerateCylinder}(M,m,n)\) forall\(f\in M\)do \(C_{h,r}\).ProjectFaceToGrid(\(f\)) endforfor\(i\gets 0\) to \(m-1\)do for\(j\gets 0\) to \(n-1\)do \(C_{h,r}\).SetWeight(\(i,j,T\)) endfor endfor

Figure 2: \(C_{h,r}(u,v)\) about various triangular mesh models. In sequence from left to right and then top to bottom: [PERSON], Rocker, Horse, Kitten, Bunny, [PERSON], Venus, Popiersie, Armadillo, and [PERSON]. ### Path Generation with Periodic B-Spline Curve

Generating the camera path involves a two-stage process: determining a camera position path and gaze path. Both paths are constructed using a third-order periodic B-spline curve, ensuring \(C^{1}\) continuity and seamless transitions at both endpoints. Control points for this curve are derived from the pre-processed grid weights of \(C_{h,r}(u,v)\). Specifically, for grids with identical \(v\) values, the center of the grid with the maximum weight is selected as the control point, resulting in \(n\) control points for the curve. Figure 3 provides a visual overview of this control point generation procedure, complete with sample weight values. Figure 3 illustrates the sample weight distribution on \(C_{h,r}(u,v)\), Figure 3 shows the grids with the maximum weights for identical \(v\) values, colored in orange. Figure 3 shows the selected control points, colored in green. We can generate a periodic B-spline curve over the bounding cylinder's lateral surface using selected control points. The B-spline curve \(B(u)\) can be expressed as Equation (1) where \(\mathbf{p}_{i}\) express the control points, and \(N_{i}^{m}\) are the B-spline basis functions with degree \(n\). The periodic B-spline curve can be obtained by constructing the control points and the knot sequence to satisfy the Equations (2) and (3). \(\triangle_{i}\) expresses knot interval between \(i\)th knot and \(i+1\)th knot and \(K\) means the number of knots of the curve. \[B(u)=\mathbf{p}_{0}N_{0}^{n}(u)+\dots+\mathbf{p}_{D-1}N_{D-1}^{n}(u),0\leq u\leq 1 \tag{1}\]

\[\mathbf{p}_{0}=\mathbf{p}_{D-(n+1)},\mathbf{p}_{1}=\mathbf{p}_{D-n},\dots, \mathbf{p}_{n}=\mathbf{p}_{D-1} \tag{2}\]

\[\triangle_{0},\triangle_{1},\dots,\triangle_{n},\triangle_{n+1},\dots, \triangle_{K-(n+3)},\triangle_{0},\triangle_{1},\dots,\triangle_{n} \tag{3}\]

Applying the initially generated curve directly to the camera position or gaze path can lead to excessive camera movement, depending on the distribution or configuration of the control points. This may cause visual instability or a shaky camera effect. Moreover, it may accidentally exclude certain areas of the triangle mesh from the camera's field of view. To address these issues, we adjust the radius of the \(C_{h,r}(u,v)\) when generating the camera position path. If the ratio of \(h\) to \(r\) is greater than 2, we multiply \(r\) by 6; otherwise, we multiply \(r\) by 4. Subsequently, we multiply the generated curve by the scaling factor. Specifically, the camera position path is modified by a factor of 0.25, while the camera gaze path is scaled by a factor of 0.5 relative to the original periodic B-spline curve.