{
 "id": "heat-method-geodesics",
 "title": "Heat Method for Geodesic Distance",
 "aliases": [],
 "domain": "geometry",
 "subdomain": "geodesics",
 "stage": "geometry",
 "realtime": "interactive",
 "platforms": [
  "cpu",
  "python",
  "blender"
 ],
 "year_introduced": 2013,
 "inputs": [
  "mesh",
  "point-cloud"
 ],
 "outputs": [
  "texture"
 ],
 "style": "both",
 "dynamic": "static",
 "summary": "Computes geodesic distance on meshes by letting heat diffuse briefly from the source, normalising its gradient, then solving a Poisson equation for the distance function. Two sparse solves, prefactorable, with no wavefront tracking.",
 "how_it_works": "Step one: solve one backward-Euler step of heat flow from the source, producing a smooth heat distribution u. Step two: take the gradient of u at each face and normalise it, giving a unit vector field that points away from the source. The direction is accurate even for a short time; the magnitudes are not. Step three: find the scalar function whose gradient best matches that field, by solving a Poisson equation (the Laplacian equals the divergence). Subtract the minimum so the source has zero. All three steps use the same cotan Laplacian matrix, so you factor it once and re-solve for different sources in milliseconds. The method extends to point clouds and other discretizations.",
 "when_to_use": "Choose it for repeated geodesic queries on a fixed mesh: texture mapping, remeshing guides, skinning weights, vector-field design, drawing paths. Prefer exact window propagation (e.g. MMP) when you need exactness, and `intrinsic-delaunay-triangulation` plus this method when mesh quality is poor and robustness matters.",
 "cost": {
  "class": "interactive",
  "notes": "Prefactor the Laplacian once; each source costs a backsolve. Scales to millions of faces with sparse Cholesky."
 },
 "failure_modes": [
  "Smoothing time step too large rounds off distance contours near sharp or thin features",
  "Poor triangle quality (needle triangles) degrades the cotan Laplacian and the result",
  "Not exact; errors are a few percent on regular meshes",
  "Non-manifold or disconnected meshes need regularisation"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/3131280",
   "type": "paper",
   "title": "The heat method for distance computation",
   "authors": [
    "Keenan Crane",
    "Clarisse Weischedel",
    "Max Wardetzky"
   ],
   "year": 2017,
   "venue": "Communications of the ACM",
   "url": "https://doi.org/10.1145/3131280",
   "ids": {
    "doi": "10.1145/3131280"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3131280",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3131280",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3131280",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3131280",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3131280",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "crane2017heat"
  },
  {
   "role": "implementation",
   "key": "gh:nmwsharp/geometry-central",
   "type": "code",
   "title": "nmwsharp/geometry-central",
   "description": "Applied 3D geometry in C++, with a focus on surface meshes.",
   "authors": [
    "nmwsharp"
   ],
   "year": 2017,
   "venue": "GitHub",
   "url": "https://github.com/nmwsharp/geometry-central",
   "ids": {
    "repo": "nmwsharp/geometry-central"
   },
   "license": "MIT",
   "extra": {
    "stars": 1347,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-25T17:30:47Z",
    "language": "C++",
    "homepage": "https://geometry-central.net",
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/nmwsharp/geometry-central",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/nmwsharp/geometry-central",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/nmwsharp/geometry-central",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/nmwsharp/geometry-central",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/nmwsharp/geometry-central",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/nmwsharp/geometry-central",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "nmwsharp2017nmwsharp"
  },
  {
   "role": "tutorial",
   "key": "url:https://www.cs.cmu.edu/~kmcrane/Projects/HeatMethod",
   "type": "tutorial",
   "title": "The Heat Method for Distance Computation",
   "authors": [
    "Keenan Crane"
   ],
   "year": null,
   "venue": "cs.cmu.edu",
   "url": "https://www.cs.cmu.edu/~kmcrane/Projects/HeatMethod",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20260930185319/https://www.cs.cmu.edu/~kmcrane/Projects/HeatMethod/",
     "timestamp": "20260930185319"
    },
    "page_title": "Keenan Crane - The Heat Method for Distance Computation",
    "host": "cs.cmu.edu",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://www.cs.cmu.edu/~kmcrane/Projects/HeatMethod → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://www.cs.cmu.edu/~kmcrane/Projects/HeatMethod → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://www.cs.cmu.edu/~kmcrane/Projects/HeatMethod → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 0.95,
   "__bib": "craneheat"
  }
 ],
 "presets": [
  {
   "id": "heat-method-geodesics-live",
   "title": "Heat method geodesics — intrinsic distance isolines & normalized heat gradient on 3D manifold",
   "runtime": "glsl-fragment",
   "params": {
    "P_CONTOUR_FREQ": 14,
    "P_DIFFUSION_TIME": 0.65,
    "P_HEAT_GLOW": 1,
    "P_GRADIENT_FIELD": 0.72
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_CONTOUR_FREQ = 14.0; // P Isoline Freq [4.0, 28.0, 0.5]\nconst float P_DIFFUSION_TIME = 0.65; // P Heat Time t [0.15, 2.0, 0.05]\nconst float P_HEAT_GLOW = 1.0; // P Source Heat [0.0, 2.0, 0.05]\nconst float P_GRADIENT_FIELD = 0.72; // P Gradient Lines [0.0, 1.5, 0.05]\n\nmat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }\n\n// Sculpted genus-1 undulating manifold (fluted torus)\nfloat mapManifold(vec3 p) {\n  vec3 q = p;\n  q.xz = rot2(iTime * 0.28) * q.xz;\n  q.xy = rot2(0.42) * q.xy;\n  float ang = atan(q.z, q.x);\n  float rMajor = 0.76 + 0.07 * sin(ang * 3.0);\n  vec2 tq = vec2(length(q.xz) - rMajor, q.y);\n  float phi = atan(tq.y, tq.x);\n  float rMinor = 0.30 + 0.035 * cos(phi * 4.0 + ang * 2.0);\n  return (length(tq) - rMinor) * 0.8;\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.002, 0.0);\n  return normalize(vec3(\n    mapManifold(p + e.xyy) - mapManifold(p - e.xyy),\n    mapManifold(p + e.yxy) - mapManifold(p - e.yxy),\n    mapManifold(p + e.yyx) - mapManifold(p - e.yyx)\n  ));\n}\n\n// Compute intrinsic toroidal-manifold geodesic distance from heat source (theta0, phi0)\n// Incorporates surface metric distortion from radial/minor ripples so isolines bend over curvature\nvec2 torusCoords(vec3 p) {\n  vec3 q = p;\n  q.xz = rot2(iTime * 0.28) * q.xz;\n  q.xy = rot2(0.42) * q.xy;\n  float theta = atan(q.z, q.x);\n  float rMajor = 0.76 + 0.07 * sin(theta * 3.0);\n  vec2 tq = vec2(length(q.xz) - rMajor, q.y);\n  float phi = atan(tq.y, tq.x);\n  return vec2(theta, phi);\n}\n\nfloat wrapPi(float a) {\n  return mod(a + 3.14159265, 6.2831853) - 3.14159265;\n}\n\n// Shortest intrinsic geodesic arc length on the sculpted torus with metric curvature warp\nfloat geodesicDist(vec2 tp, vec2 src) {\n  float dTheta = wrapPi(tp.x - src.x);\n  float dPhi = wrapPi(tp.y - src.y);\n  float rEff = 0.76 + 0.30 * cos(0.5 * (tp.y + src.y));\n  float metricBump = 1.0 + 0.08 * sin(tp.x * 3.0) + 0.06 * cos(tp.y * 4.0 + tp.x * 2.0);\n  float ds1 = rEff * dTheta * metricBump;\n  float ds2 = 0.31 * dPhi * (1.0 + 0.07 * sin(tp.y * 4.0));\n  return sqrt(ds1 * ds1 + ds2 * ds2 + 1e-6);\n}\n\n// Scientific perceptually-uniform inferno/plasma palette for heat -> geodesic field\nvec3 heatPalette(float x) {\n  x = clamp(x, 0.0, 1.0);\n  vec3 c0 = vec3(0.06, 0.09, 0.26);\n  vec3 c1 = vec3(0.18, 0.44, 0.68);\n  vec3 c2 = vec3(0.86, 0.34, 0.24);\n  vec3 c3 = vec3(1.00, 0.88, 0.42);\n  if (x < 0.35) return mix(c0, c1, x / 0.35);\n  if (x < 0.72) return mix(c1, c2, (x - 0.35) / 0.37);\n  return mix(c2, c3, (x - 0.72) / 0.28);\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n\n  vec3 ro = vec3(0.0, 0.15, 2.75);\n  vec3 rd = normalize(vec3(uv, -1.5));\n\n  // Clean technical studio slate backdrop\n  vec3 col = mix(vec3(0.04, 0.055, 0.08), vec3(0.11, 0.135, 0.18), smoothstep(-0.6, 0.6, uv.y));\n  vec2 g = abs(fract(uv * 10.0 - 0.5) - 0.5);\n  col += vec3(0.03, 0.04, 0.06) * smoothstep(0.025, 0.0, min(g.x, g.y));\n\n  float t = 0.0;\n  bool hit = false;\n  for (int i = 0; i < 64; i++) {\n    float d = mapManifold(ro + rd * t);\n    if (d < 0.002) { hit = true; break; }\n    t += d;\n    if (t > 10.0) break;\n  }\n\n  if (hit) {\n    vec3 p = ro + rd * t;\n    vec3 n = calcNormal(p);\n    vec2 tp = torusCoords(p);\n\n    // Moving heat impulse source on manifold\n    vec2 src = vec2(sin(iTime * 0.45) * 1.1, cos(iTime * 0.35) * 0.8);\n    float dist = geodesicDist(tp, src);\n\n    // Step 1 of Heat Method: heat kernel u(x,t) = exp(-d^2 / (4t))\n    float diffT = max(P_DIFFUSION_TIME, 0.12);\n    float uHeat = exp(-dist * dist / (2.4 * diffT));\n\n    // Step 2: normalized negative gradient X = -grad(u)/|grad(u)| = grad(d)\n    vec2 eps = vec2(0.015, 0.0);\n    float dTx = geodesicDist(tp + eps.xy, src) - geodesicDist(tp - eps.xy, src);\n    float dTy = geodesicDist(tp + eps.yx, src) - geodesicDist(tp - eps.yx, src);\n    vec2 gradDir = normalize(vec2(dTx, dTy) + 1e-5);\n    float flowAngle = atan(gradDir.y, gradDir.x);\n\n    // Geodesic distance isolines (solution to Poisson equation div(X) = laplacian(phi))\n    float freq = clamp(P_CONTOUR_FREQ, 3.0, 32.0);\n    float isoWave = abs(fract(dist * freq * 0.38 - iTime * 0.25) - 0.5);\n    float isoLine = smoothstep(0.065, 0.015, isoWave);\n    float majorLine = smoothstep(0.045, 0.01, abs(fract(dist * freq * 0.095 - iTime * 0.0625) - 0.5));\n\n    // Subtle orthogonal gradient flow streaks (-grad u / |grad u|)\n    float flowStripe = smoothstep(0.86, 0.98, 0.5 + 0.5 * cos(flowAngle * 14.0));\n    float gradVis = flowStripe * smoothstep(0.08, 0.45, dist) * clamp(P_GRADIENT_FIELD, 0.0, 1.5) * 0.24;\n\n    // Color map combining geodesic distance ramp + diffused heat core\n    vec3 baseCol = heatPalette(1.0 - clamp(dist * 0.38, 0.0, 1.0));\n    baseCol = mix(baseCol, vec3(1.0, 0.96, 0.84), pow(uHeat, 2.2) * 0.55 * clamp(P_HEAT_GLOW, 0.0, 2.0));\n\n    // Subtle studio lighting over the manifold\n    vec3 l1 = normalize(vec3(0.65, 0.82, 0.55));\n    vec3 l2 = normalize(vec3(-0.7, -0.2, 0.6));\n    float diff1 = max(dot(n, l1), 0.0);\n    float diff2 = max(dot(n, l2), 0.0);\n    vec3 hVec = normalize(l1 - rd);\n    float spec = pow(max(dot(n, hVec), 0.0), 36.0) * 0.45;\n    float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0) * 0.28;\n\n    col = baseCol * (0.28 + 0.82 * diff1 + 0.25 * diff2) + vec3(spec) + vec3(0.45, 0.68, 1.0) * rim;\n    col = mix(col, vec3(0.05, 0.07, 0.11), isoLine * 0.52);\n    col = mix(col, vec3(1.0, 0.98, 0.90), majorLine * 0.72);\n    col += vec3(0.85, 0.92, 1.0) * gradVis;\n\n    // Bright heat source emitter beacon\n    float srcSpot = smoothstep(0.11, 0.025, dist);\n    col += vec3(1.8, 1.15, 0.45) * srcSpot * max(P_HEAT_GLOW, 0.0);\n  }\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "heat-method-geodesics",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:50:13.852Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.5694,
      "std": 0.2219,
      "unique_colors": 343
     },
     "image": "/specimens/heat-method-geodesics-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "intrinsic-delaunay-triangulation",
  "tufted-laplacian",
  "lscm-uv-unwrapping"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "intrinsic-delaunay-triangulation",
   "why": "Run on the intrinsic Delaunay triangulation for robustness on bad meshes."
  },
  {
   "id": "tufted-laplacian",
   "why": "The tufted Laplacian lets the method run on non-manifold or messy meshes."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/geometry/heat-method-geodesics.json"
 },
 "solves": [
  "need distance along a mesh surface, not straight line",
  "many geodesic queries on the same mesh",
  "draw paths or fields across a model surface",
  "wavefront propagation for distance is too heavy",
  "compute skinning weights from surface distance"
 ],
 "authority": "Crane et al., 2017",
 "url": "https://texelatlas.vercel.app/t/heat-method-geodesics/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 35.32,
  "tier": "heavy",
  "p50_ms": 1.1619,
  "p95_ms": 1.2168,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "heat-method-geodesics-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 30.5,
   "tier": "heavy",
   "p50_ms": 0.4849,
   "p95_ms": 0.4973,
   "speedup_x": 2.4,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 20.52,
   "tier": "heavy",
   "p50_ms": 0.5909,
   "p95_ms": 0.602,
   "speedup_x": 1.97,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}