Midpoint method to obtain geodesics in 3D

antoni.parellada shared this question 2 years ago
Needs Answer

I am trying to minimize the distance between two points on a surface in 3D through the midpoint method, which is described here, and could be implemented with the following chunk of code (or pseudocode) in MatLab:

Program 1 Midpoint Search
// Iteratively refines a given path
// S: a surface I^2--->R^3
// pts: a sequence of points in I^2
// n: the number of iterations
function Midpoint_Search(S, pts, n)
for n iterations
for i=1 to length of pts
// Map the points onto S
pts2(i) = S(pts(i))
for i=1 to length of pts
// Take midpoints
midpts(i) = (pts2(i) + pts2(i+1)) * 0.5
for i=1 to length of midpts
// find the closest point on the surface to midpts(i)
pts(i) = argmin_p ||S(p)-S(midpts(i))||
// argmin can be done in matlab using fminsearch.
Thanks to @mathmagic I have now a ggb file (attached) that calculates the distance between two points on a surface, and it seems like iterating to find the shortest distance between those two points could be feasible if there is some sort of way to create a loop and a way to find a point on the surface closest to the average of two vectors, which seems to be given by the function fminsearch in matlab.

© 2023 International GeoGebra Institute