# Least-Squares Estimation of Tangent Space for a Triangular Mesh
## 3 Method
### Solution Method for Unconstrained Normal Vectors  
To produce coherent orthonormal tangent spaces across neighboring vertices, we adopt a least-squares estimation approach for optimal rotation between two sets of corresponding points. Let \(\mathcal{N}_{i}\) represent the 1-ring neighborhood of a vertex, \(i\), which consists of the vertices of the triangles sharing vertex \(i\), as illustrated in Figure 3. We consider the vertices of \(\mathcal{N}_{i}\) in both texture space and world space as two sets of corresponding points. Figure 3: Least-squares estimation of a rigid transformation that optimally aligns the positions of the 1-ring neighbors of a vertex in texture space with their corresponding positions in world space. (**a**) Texture space; (**b**) World space. Figure 2: Seams are represented as magenta lines in texture space and world space. The block arrows illustrate directions near the seam edges. The red, green, and blue axes represent the tangent, bitangent, and normal vectors of the tangent spaces. (**a**) Texture space; (**b**) World space; (**c**) Tangent space. Without loss of generality, we embed texture space within world space by aligning the \(u\)-, \(v\)-, and \(w\)-axes of texture space with the \(x\)-, \(y\)-, and \(z\)-axes of world space, respectively. Here, the virtual \(w\)-axis is defined as the cross product of the \(u\)- and \(v\)-axes. Let \(\bar{\mathbf{p}}_{j}=(u_{j},v_{j},0)\) represent the texture coordinates of vertex \(j\), and \(\mathbf{p}_{j}=(x_{j},y_{j},z_{j})\) represent the corresponding world coordinates. We then seek the optimal rotation \(\mathbf{R}_{i}\) that minimizes  
\[\sum_{j\in\mathcal{N}_{i}}w_{ij}\|\mathbf{R}_{i}(\bar{\mathbf{p}}_{j}-\bar{ \mathbf{p}}_{i})-(\mathbf{p}_{j}-\mathbf{p}_{i})\|^{2}, \tag{7}\]  
where \(w_{ij}=\frac{1}{2}(\cot\alpha_{ij}+\cot\beta_{ij})\) is the cotangent weight for an edge, \(e_{ij}\), with the opposite angles \(\alpha_{ij}\) and \(\beta_{ij}\)[15; 17]. This optimal rotation can be interpreted as a local space transformation. The rotation, \(\mathbf{R}_{i}\), transforms the \(u\)-, \(v\)-, and \(w\)-axes of texture space into \(\mathbf{t}_{i}\), \(\mathbf{b}_{i}\), and \(\mathbf{n}_{i}\), respectively, defining the tangent space at vertex \(i\). The \(u\)-, \(v\)-, and \(w\)-axes are algebraically represented as \((1,0,0)\), \((0,1,0)\), and \((0,0,1)\) in the embedded world space. Consequently, the first, second, and third columns of \(\mathbf{R}_{i}\) correspond to \(\mathbf{t}_{i}\), \(\mathbf{b}_{i}\), and \(\mathbf{n}_{i}\), respectively. Therefore, the optimal rotation, \(\mathbf{R}_{i}\), directly defines the tangent space: \(\mathbf{T}_{i}=[\mathbf{t}_{i}|\mathbf{b}_{i}|\mathbf{n}_{i}]=\mathbf{R}_{i}\). Note that \(\mathbf{t}_{i}\), \(\mathbf{b}_{i}\), and \(\mathbf{n}_{i}\) are mutually orthogonal unit vectors because they constitute the three column vectors of the rotation matrix, \(\mathbf{R}_{i}\). The optimal rotation, \(\mathbf{R}_{i}\), can be obtained using the polar decomposition of the covariance matrix:  
\[\mathbf{A}_{i}=\sum_{j\in\mathcal{N}_{i}}w_{ij}(\mathbf{p}_{j}-\mathbf{p}_{i} )(\bar{\mathbf{p}}_{j}-\bar{\mathbf{p}}_{i})^{\mathrm{T}}=\mathbf{R}_{i} \mathbf{S}_{i}. \tag{8}\]  
The third column of \(\mathbf{A}_{i}\) is the \(3\times 1\) zero vector because the third coordinate of every \((\bar{\mathbf{p}}_{j}-\bar{\mathbf{p}}_{i})\) is zero. This implies that the rank of \(\mathbf{A}_{i}\) is 2. Nevertheless, the optimal rotation is unique because the rank is only one less than the dimension, as stated in [11]. To ensure robust computation of the polar decomposition, even with \(\mathbf{A}_{i}\) of rank 2, we utilize singular value decomposition. In addition, for accurate computation of singular value decomposition we employ the Jacobi method provided in the Eigen library (eigen.tuxfamily.org).