# Approach to measure distance between points along mesh

Hi. I’m interested in measuring the distance between points along a mesh. A simple example would be the circumference of a sphere - the actual meshes are more dynamic than a sphere. As a test I’ll be trying to measure the distance between points along the stanford bunny library model. I would also like to show this distance (a strip along the surface)

I’m posting here in hopes of getting a few ideas to approach this. Below is what I’m going to start on, please let me know if I should divert my attention to other efforts.

Approach:

1. Define points (at first a 360 degree slice at some height)
2. Create ray cast intersection function to get location of mesh from some interior or exterior observation point (start at some inner section centroid)
3. Call the function at intermediate points along the section (start with measurement at 1 degree)
4. Calculate length along mesh by sum of change in measurements

I will also investigate creating a “path” at the intersection (of plane and mesh) and tracing or following / measuring the path.

I’m wondering about alternative approaches or built in functions - Any thoughts would be appreciated.

Thanks.

I’ll post PG’s as I move forward.

PG placeholder - casting rays along height

1 Like

Latest PG here. This gets a bunch of points about 180 degrees at any height by casting a ray and getting the intersection.

I’m now going to use each of the points to form a curve / path and see if I can get length from that object.
If not I’ll sum up the change in measurements. The curve will at least be a nice way to visualize.

Okay latest PG here - I am creating a curve from multiple points and then taking the curve3 length. Is this the best approach?

1 Like

Interesting problem. Which means it is not as straightforward as it might seem! First of all what do you mean by the distance between points along a mesh? Assuming you mean the shortest surface distance between two points on the surface of the mesh.

Take a bowl as a mesh with two points on the rim of the mesh. Taking a verticle slice the path between the two points would be down one side to the bottom and up the other this would be longer than taking a horizontal slice and travelling the rim of the bowl. Then again with the horizontal slice going one way round the rim will be shorter than the other.

What if one point was on the rim and the other on the outside of the bowl and further round the bowl, what angle would the slice have to be to get the shortest root?

What is the range of meshes you want to look at? How much do you want the calcultion to be done automatically and how much user intervention can there be in determining the path to take?

My latest PG is here using the skull. Throws lots of errors at various locations but does get the length along mesh for many sections!

2 Likes

thanks for your interest. In reality the geometry will be a similar set of cylindrical shapes (undulating a bit like peanuts or potatoes).

An ideal solution would act like a 3d printer slicer and calculate the length of the slice. The skull in my latest PG is a bit more shaped with multiple regions (enclosed portions) than I’ll actually have. The two points will be along some plane (height in this skull pg) making it a bit eaiser.

1 Like

Such a nice topic to read through !!! I wonder what the fastest approach will be

1 Like

This wouldn’t give the exact distance but an upper bound, but a possibility would be doing a BFS through the edges between the two points. There is a similar idea here on the Trimesh library: trimesh/shortest.py at main · mikedh/trimesh · GitHub

Searching around for geodesic distance on meshes also took me to those papers, hopefully they might give you more ideas:
http://www.numerical-tours.com/matlab/fastmarching_4bis_geodesic_mesh/