To find a geodesic for the metric m between points x1 and x2 in MATLAB, you can use the funm function to compute the matrix exponential of the metric multiplied by the path length. Here's the code:
main.m413 chars17 lines
In this code, m is the metric function, which is assumed to be a 2x2 matrix-valued function of the position vector x. x1 and x2 are the starting and ending points of the geodesic, respectively. L is the path length as a function of t (where 0<=t<=1), which is defined as the Euclidean distance between x1 and x2 multiplied by t. Finally, geo is the geodesic as a function of t, which uses the expm function to compute the matrix exponential of the metric times the path length, evaluated at x1. The resulting geodesic is then plotted using the plot function.
gistlibby LogSnag