# Approximating Geodesics in a half edge DS, how can I refine my mesh to get good approximations

I implemented Djikstra's shortest path algorithm to approximate Geodesics on arbitrary meshes. Djikstra's works, but I noticed a problem inherent to the discretization of my meshes.

Consider the following figure squence:

...

This is my current refinement algorithm which is the easiest/standard face subdivision. Now consider the approximation of a geodesic in 2 points:

The blue point is where I think the actual geodesic intersects that edge, which is quite far from where the approximated geodesic passes. However that path ISN'T wrong.

Consider a square grid. The distance between any 2 points in the grid is the manhattan distance |x| + |y|.

So as far as Djikstra's is concerned, a path that goes all the way down and then to the left has the same length as a path that goes diagonally in a staircase pattern. Refining the mesh won't change the distance either. In other words, the limit of the shortest path found by Djikstra in a regular square grid as the size of the squares goes to 0 is NOT the straigtht line connecting 2 points.

Now the actual question, does anyone know of a way to subdivide my surface that is fairly straightforward but will actually converge to the geodesic?

• Intriguing problem! If I am not mistaken, the situation is even worse than you expected in the sense that any path going through the blue point should be a little bit longer than the path you found with Dijkstra's algorithm.
– user9485
Commented Jul 21, 2020 at 14:15
• The analytic path should be shorter, but the approximation might be longer Commented Jul 21, 2020 at 15:45
• Yes, this is what I meant to say. I think you found the (unique) shortest path between the two red points, among all paths that move along the triangles' edges.
– user9485
Commented Jul 21, 2020 at 15:54
• In this specific case there's just one, but in general there might be multiple, including infinite. Commented Jul 21, 2020 at 17:02
• How can there be infinitely many shortest paths?
– user9485
Commented Jul 21, 2020 at 18:30

As you pointed out, the problem here is the discretization/subdivision of the mesh. If your mesh was made of quadrilaterals instead of triangles, the obvious subdivision strategy would be to split each quadliteral into four equally sized smaller quadliterals:

$$\hspace{2cm}$$ $$\hspace{2cm}$$

For any two points $$P_1$$ and $$P_2$$, Dijkstra's algorithm would yield sets of shortest paths between these points $$P_1$$ and $$P_2$$. The more you refine the discretization with this subdivision strategy, the more shortest paths you'll find between the two points. However, intuitively it is clear that for every subdivision level $$l\in\mathbb{N}$$ you could pick one of these shortest paths $$p_l$$ such that the sequence $$(p_l)_{l\in\mathbb{N}}$$ converges to the actual geodesic between $$P_1$$ and $$P_2$$ (with respect to some norm that has to be specified, for example the supremum norm).

Unfortunately, the same is not true for the standard subdivision strategy of splitting a triangle into four smaller triangles, which you have proven with your example. I believe that, at its core, the problem is that there is no way to reach the center of the triangle with a straight line from each of its edges. This can be achieved by splitting a triangle in each subdivision step into 6 smaller triangles like this:

$$\hspace{2cm}$$ $$\hspace{2cm}$$

I do not have a proof that this subdivision is more useful to compute geodesics with Dijkstra's algorithm, but it seems quite likely to me. I would be very interested to see what your results look like with this subdivision strategy! However, no matter what you do, in the end you may or may not end up with sets of shortest paths instead of a single shortest path. In this case you will need some kind of heuristic or additional algorithm to decide which path resembles the true geodesic most closely.

• I think you have it wrong, given the square subdivision you gave, a refinement of that will not converge towards the geodesic, because the distance between 2 points remains constant. I explained that on my original question : p Commented Jul 21, 2020 at 17:03
• Your triangle scheme has given me and Idea, so I will test that out and get back to you Commented Jul 21, 2020 at 17:04
• This is why I wrote sets of shortest paths. You always need to make sure you calculate all shortest paths and not just one random path. Then you indeed get convergence as I explained above.
– user9485
Commented Jul 21, 2020 at 18:40
• I am going to have to ask another question here before I get back to you Commented Jul 22, 2020 at 4:22
• This is not what I ended up doing but it;s probably better, my solution was just to start randomly splitting edges (I just did it this way because it;s easier in my current implementation) but this will probably work too. Commented Jul 22, 2020 at 4:46