The Heat Method
Heat Equation Formulation:
(M - t L_C) u = δ_x where L_C is cotangent Laplacian and M is lumped area. 2. Time Step t = h^2: Scaled to mean edge length h, balancing numerical stability with Varadhan's asymptotic limit. 3. Linear System: Solvable via a single sparse Cholesky factorization for millisecond queries.1import numpy as np23def integrate_heat_diffusion(L_cot, M_lumped, source_idx, t_step=0.05):4 """5 Step 1 of the Heat Method (Crane et al. 2013).6 Integrate backward Euler heat diffusion: (M - t*L) * u = delta_source.7 t_step is chosen as h^2 (mean edge length squared).8 """9 n = L_cot.shape[0]10 rhs = np.zeros(n)11 rhs[source_idx] = 1.0 # Dirac delta heat source1213 # System matrix A = M - t * L_cot (positive definite)14 A = np.diag(M_lumped) - t_step * L_cot15 u = np.linalg.solve(A, rhs)16 return u
The Heat Method: Heat Diffusion Step: Rather than running slow Dijkstra or Fast Marching on discrete graph edges, the Heat Method computes exact polyhedral geodesic distances by simulating short-time heat diffusion from a source vertex du/dt = Δu. Heat flows smoothly across triangle interiors independent of mesh tessellation.
Vector Field Integration:
1import numpy as np2from scipy.sparse.linalg import spsolve34def compute_heat_geodesics(vertices, faces, M, L_cot, source_idx, t):5 """6 The 3-step Heat Method for Geodesic Distance (Crane et al. 2013).7 """8 n_verts = len(vertices)9 u0 = np.zeros(n_verts)10 u0[source_idx] = 1.01112 # Step 1: Integrate heat flow (M - t * L_cot) u = u013 heat_u = spsolve(M - t * L_cot, u0)1415 # Step 2: Evaluate face gradients and normalize X = -grad_u / ||grad_u||16 div_X = np.zeros(n_verts)17 for i, j, k in faces:18 vi, vj, vk = vertices[i], vertices[j], vertices[k]19 e_ij, e_jk, e_ki = vj - vi, vk - vj, vi - vk20 normal = np.cross(e_ij, -e_ki)21 dbl_area = np.linalg.norm(normal)22 n_hat = normal / dbl_area2324 grad_u = (25 heat_u[i] * np.cross(n_hat, e_jk) +26 heat_u[j] * np.cross(n_hat, e_ki) +27 heat_u[k] * np.cross(n_hat, e_ij)28 ) / dbl_area29 X = -grad_u / (np.linalg.norm(grad_u) + 1e-12)3031 # Integrated divergence per vertex using cotangent weights32 cot_i = -np.dot(e_ij, e_ki) / dbl_area33 cot_j = -np.dot(e_jk, e_ij) / dbl_area34 cot_k = -np.dot(e_ki, e_jk) / dbl_area35 div_X[i] += 0.5 * (cot_j * np.dot(e_ij, X) + cot_k * np.dot(-e_ki, X))36 div_X[j] += 0.5 * (cot_k * np.dot(e_jk, X) + cot_i * np.dot(-e_ij, X))37 div_X[k] += 0.5 * (cot_i * np.dot(e_ki, X) + cot_j * np.dot(-e_jk, X))3839 # Step 3: Solve Poisson equation L_cot * phi = div_X40 phi = spsolve(L_cot, div_X)41 return phi - phi.min()
The Heat Method: Vector Field & Poisson Solve: Geodesics satisfy the Eikonal equation‖∇ϕ‖ = 1. Varadhan's formula guarantees that as t → 0, -∇u / ‖∇u‖ aligns precisely with the geodesic gradients ∇ϕ. Solving the Poisson problem Δϕ = ∇ · X integrates this vector field back into exact geodesic distances ϕ.
Related Concepts
Volume, mass properties, and surface curvature.
Exact polyhedral surface area via cross-product magnitudes and enclosed volume via signed tetrahedral summation.
Computing shell and solid centroids, 3x3 inertia tensors, principal axes of inertia, and static balance.