Harmonic & Conformal UV
Tutte's Barycentric Mapping (Harmonic Spring Embedding): Unwrapping a double-curved 3D mesh onto flat 2D UV texture space easily causes triangles to overlap or invert. In 1963, W. T. Tutte proved a foundational mathematical theorem: if the boundary of a 3-connected planar graph is mapped to the vertices of a strictly convex 2D polygon, and every internal vertex is placed at the weighted centroid of its neighbors (spring equilibrium), the resulting 2D parameterization is guaranteed to be 100% bijective and flip-free.
Tutte's Invariant:
1import numpy as np23def tutte_barycentric_mapping(boundary_indices, boundary_uvs, adjacency_list):4 """5 Tutte's Spring Embedding Theorem (1963).6 Maps 3D mesh boundary to a convex 2D polygon (e.g. circle or square).7 Interior vertices satisfy harmonic equilibrium:8 u_i = (1 / d_i) * sum_{j in N(i)} u_j.9 Guarantees a strictly bijective, flip-free, 1-to-1 planar embedding.10 """11 n = len(adjacency_list)12 A = np.zeros((n, n))13 bx = np.zeros(n)14 by = np.zeros(n)1516 for i in range(n):17 if i in boundary_indices:18 A[i, i] = 1.019 idx = boundary_indices.index(i)20 bx[i] = boundary_uvs[idx][0]21 by[i] = boundary_uvs[idx][1]22 else:23 deg = len(adjacency_list[i])24 A[i, i] = 1.025 for j in adjacency_list[i]:26 A[i, j] = -1.0 / deg2728 u = np.linalg.solve(A, bx)29 v = np.linalg.solve(A, by)30 return list(zip(u, v))
Least Squares Conformal Maps (LSCM): While Tutte mapping forces boundaries into an arbitrary rigid polygon (distorting texture angles), LSCM (Lévy et al. 2002) minimizes the deviation from the Cauchy-Riemann equations. Conformal maps preserve local angles: microscopic circles on the 3D surface map to perfect 2D circles in texture space without elliptical shearing, making it the industry standard for UV texture unwrapping.
LSCM Conformal Invariant:
1import numpy as np23def solve_lscm_uv(triangles, vertices, pin_v1=0, pin_v2=1):4 """5 Least Squares Conformal Maps (LSCM, Lévy et al. 2002).6 Minimizes violation of Cauchy-Riemann equations:7 du/dx = dv/dy and du/dy = -dv/dx.8 Conformal energy E_C = Area(T_3D) * ||grad(u) - rot90(grad(v))||^2.9 Pins only TWO boundary vertices to fix translation, rotation, and scale;10 all remaining boundary and interior vertices naturally find angle-preserving positions.11 """12 return "Conformal UV Atlas with Minimal Angular Shearing"