Heat Method

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:
colours
(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.


35 Likes

Love it! :heart_eyes:

1 Like


With the contours as actual curves:
HeatMethod_ContourCurves.gh (161.7 KB)

(showing them just with texture is faster while iterating, so better to only enable the contouring script when it’s done)

9 Likes

So good… Remembers lessons from LGG EPFL, but I never knew how to do this in .NET

1 Like

Daniel, you outdo yourself on a daily basis…This is just awesome!

1 Like

Do you think it would also be possible to make it work for pointclouds following Keenan Crane tweet?

Yes - in theory as long as you have a way to compute the Laplacian and the gradient on it, you can use all sorts of geometric structures, not just manifold triangular meshes. They wrote about one way of applying it to point clouds in the original paper (there’s a video on it here). There they use the method described in this paper to get the Laplacian of the point cloud, though it seems with this new work on non-manifold triangulations they say it is a quicker/more accurate way of calculating this.
I haven’t read the new paper properly yet (didn’t the preprint just go up a few hours ago?).

Yes, the project is here https://www.cs.cmu.edu/~kmcrane/Projects/NonmanifoldLaplace/index.html

It hurts to read the formulas.

1 Like

Hello Daniel,

I have tested your tool with a mesh sphere. But I did not get a good result. Am I doing something wrong?

2020-07-04 08_07_05-Rhinoceros 6 Commercial- - Perspective

@mahanmotamedi1991 Looks to me this needs a triangular mesh, did you try that?

@Petras_Vestartas or others can you explain what this is useful for?

Yes, I should have mentioned, the mesh needs to be triangulated @mahanmotamedi1991
@Gijs - ‘What this is useful for?’
I had a few things in mind
One direct one is engraving style hatching (Like in Gustave Doré or Albrecht Dürer’s work) - a while back I made this by taking curves on a surface and thickening them according to shading:


When the curves follow the shape I think it conveys the 3d form better than simply taking contours with parallel planes. For the image above I achieved this in a rather manual way, by designing a surface with isocurves roughly matching the hand curvature directions and taking the intersection with their extrusions:

With this geodesic heat method now implemented, it would be easy to quickly and automatically generate these curves on any shape.

Another application I’m thinking of for this is generating skinning weights for deformation. In this work I’m using a function in 3d space to control the falloff of the influence of the editing handles. One problem with this is that sometimes you can have handles which start close together in 3d space, but not close in the curved 2d space of the surface.


Say you want an edit handle on the foot. If you use simple 3d distance based falloff like on the left, when you edit that handle, it will drag some of the adjacent leg with and cause strange distortions. If instead you use a falloff based on geodesic distance like on the right, then the handle will edit the appropriate local area.

Those are just 2 applications off the top of my head that I’m personally interested in using this for right now, but I think there are many other potential uses. It’s a fairly general way of getting a notion of distances in the space of a surface, without having to explicitly trace geodesic curves for each point.

12 Likes

For falloffs indeed it would be a great application! In fact I think it would be better to get rid of the soft edit commands and instead add a global falloff tool that is independent from any command. Just like (de)activating gridsnap, object etc. But I’m afraid that’s a massive task. Maybe Rhino 9?

Now that I think of it, another application would be paint/sculpt masking (in case that ever gets added to Rhino)

Here would be a use case in digital fabrication:
Automatic Machine Knitting of 3D Meshes

Quite specific, I guess. Anyway, the time function they refer to in the paper seems to be a variation of a geodesic method (like heat method, marching cubes, etc.). Please correct me if I’m wrong about this.

4 Likes

should this work with an open mesh? It gives a result, just not the one I would expect. For example, if I make a single face brep, like a patch, triangulate, and put the heat point in the corner, the contours don’t seem to emanate from the heat point.

Hi Wes,
In the script above, I’ve simply fixed the boundary values at a constant value (the Dirichlet boundary conditions Keenan refers to here).
I’ll make another version now with the option to leave the boundary values free.

1 Like

It would be nice to have it for open meshes, it would super useful for generating tilings for shell structures, which are not rectangular.

3 Likes

Thanks Daniel,
That would be great, or if you just point me in the right direction to modify the current code…

Here’s an update that works also with open meshes
HeatMethod_Boundary.gh (88.4 KB)

As it is it gives you this, which seems to be the best match for geodesic distances:

If you look in the code there are also a couple of bools you can switch to get some different non geodesic results

If you don’t fix the boundary during the first step, the gradient ends up tangent at the boundary.
(so setting fixBoundary = false and keepFixed = false)


whereas if you keep the boundary values fixed also during the Poisson step, you get the gradient perpendicular to the boundary:
(so setting fixBoundary = true and keepFixed = true)

12 Likes

I don’t know if I’ll ever use these, but this topic is so pleasing to stalk.
Thanks for sharing !

5 Likes

Daniel work is awesome and offers many possibilities but for pure geodesic distance I think the plugin is more useful


One day I must update mine
https://www.grasshopper3d.com/m/discussion?id=2985220%3ATopic%3A1338612
4 Likes