# Least-Squares Estimation of Tangent Space for a Triangular Mesh
## 3 Method
### Texture Space Alignment for Seams  
Vertex duplicates on seams are individually indexed, leading to the independent computation of their tangent spaces without special consideration. To address this issue, it is necessary to identify these duplicated vertices and compute their tangent spaces while considering their neighboring vertices collectively. This approach is similar to that described in [2], where vertex duplicates are identified and their tangent vectors are averaged and set equal to each other if they align in similar directions. However, our method differs from [2] in that we apply a rigid transformation in texture space to each set of triangles adjacent to each duplicated vertex, as illustrated in Figure 5. This transformation aims to align both sides of every seam as closely as possible. The vertices aligned in this manner within texture space are then used to estimate the optimal rotation for the corresponding vertices in world space. Our approach is motivated by the fact that seams were initially placed only at their current location during the texture unwrapping process, but they could potentially have been relocated elsewhere through neighboring triangles. Therefore, when computing the tangent space, neighboring triangles should be considered across seams.  
Consider a vertex, \(i\), with \(n\) seams, as depicted in Figure 5, where \(n=3\) for simplicity. The duplicated vertices are labeled as \(i_{j}\) for \(j\in[1,n]\), with \(i_{1}=i\) without loss of generality. For each seam, \(j\), matching edges are identified as ordered pairs \((i_{j},k_{j})\) and \((i_{j+1},l_{j+1})\), utilizing circular indexing for \(j\). The triangles adjacent to vertex \(i_{j}\) for \(j\in[2,n]\) undergo a rigid transformation that translates vertex \(i_{j}\) to coincide with vertex \(i_{1}\). This transformation also rotates the two seam edges by \(\bar{\mathbf{R}}_{i_{j}}\) in texture space to optimally align them with their matching edges in a least-squares sense. The notation \(\bar{\mathbf{R}}\) is used to distinguish the rotation in texture space from the rotation for the tangent space. Thus, the optimal texture  
Figure 4: Least-squares estimation for a constrained normal vector. The 1-ring neighbors are projected onto the plane perpendicular to the normal vector before computing the tangent space. (**a**) Texture space; (**b**) World space.  
space alignment can be formulated as finding the rotation matrices, \(\bar{\mathbf{R}}_{ij}\), for all \(j\in[2,n]\) that minimize  
\[\sum_{j=1}^{n}\|\bar{\mathbf{R}}_{ij}(\bar{\mathbf{p}}_{kj}-\bar{\mathbf{p}}_{ ij})-\bar{\mathbf{R}}_{ij+1}(\bar{\mathbf{p}}_{j+1}-\bar{\mathbf{p}}_{j+1})\|^{2}, \tag{12}\]  
where \(\bar{\mathbf{R}}_{i_{1}}\) is set to \(\mathbf{I}\) for notational convenience.  
Solving the optimal rotations, \(\bar{\mathbf{R}}_{ij}\)s, simultaneously can be challenging. Instead, we adopt an iterative approach to optimize \(\bar{\mathbf{R}}_{ij}\) for \(j\in[2,n]\), assuming that only \(\bar{\mathbf{R}}_{ij}\) can change while the others are fixed. The optimal rotation \(\bar{\mathbf{R}}_{ij}\) is then obtained using the polar decomposition of the covariance matrix:  
\[\bar{\mathbf{A}}_{ij}=\bar{\mathbf{R}}_{ij+1}(\bar{\mathbf{p}}_{j+1}-\bar{ \mathbf{p}}_{j+1})(\bar{\mathbf{p}}_{kj}-\bar{\mathbf{p}}_{ij})^{\mathrm{T}}+ \bar{\mathbf{R}}_{ij-1}(\bar{\mathbf{p}}_{kj-1}-\bar{\mathbf{p}}_{j-1})(\bar{ \mathbf{p}}_{lj}-\bar{\mathbf{p}}_{j})^{\mathrm{T}}=\bar{\mathbf{R}}_{ij} \bar{\mathbf{S}}_{ij}. \tag{13}\]  
A good initial guess is crucial in reducing the number of iterations. We sequentially align edge \((i_{j},l_{j})\) with edge \((i_{j-1},k_{j-1})\) by rotating the triangles adjacent to vertex \(i_{j}\) and set the rotation as an initial guess of \(\bar{\mathbf{R}}_{ij}\) for \(j\in[2,n]\). Starting from these initial guesses, iterative optimization is performed until there are no significant changes in \(\bar{\mathbf{R}}_{ij}\)s.