A script demonstrating the Heat Method for Distance Computation, as described here
This came up recently in another thread, and I thought others might find it an interesting example. It is a fast way of getting approximate geodesic distances from a given point to all points on a mesh.
Here solved in an iterative fashion, without any extra numerics library. This is not the fastest way to do it, but it does let you see what’s going on and interact with it.
HeatMethod2.gh (163.7 KB) (*edit - updated to include output toggle)
To run this you’ll need Plankton installed, and to set the reference assembly location to this when you first open the definition.
There are 2 stages to finding the geodesic distance field - first the diffusion of the heat out from the given point (or points), then taking the normalised gradient of this and generating a new scalar field with this gradient. This is controlled by the ‘Poisson’ toggle - start with it off, let the heat spread across the surface, then turn it on the get the distance field.
The definition also uses an image texture to show the values - you can use any image here (note it only uses the values along the left vertical edge) - here’s the one I used:
(you can download this and set the location in the ‘path’ input)
Use the ‘textureScale’ slider to control the density of the stripes.
If you want the actual scalar field values or the gradient vector per vertex, set the ‘Output’ toggle to true. Outputting these values slows things down slightly, so leave it off if you don’t need them.