// *** Script computing the shortest path between Paris and Tokyo *** clf() // Earth as an ellipsoide : [a,b,c] = (6378137,6378137,6356752) // Paris and tokyo coordinates : // Paris : 48° 51' 44" N 2° 21' 3" E // Tokyo : 35° 40' N 139° 45' E lat1 = [48,51,44,1] lat2 = [35,40,0,1] lon1 = [2,21,3,-1] lon2 = [139,45,0,-1] // Discretisation of theta and phi [n,m] = (10,5) // To get a mesh of the earth (one line of A is describing an edge : [node1,node2,length]) A = MaillageEllipsoide(a,b,c,n,m); // To number all the nodes (line i = node n°1) S = NumerotationSommets(A,n,m); // To convert A in a matrix D : dij = length between i and j if (i,j) is an edge or %inf D = Aretes2MatriceDistance(A,S,n,m); // To get the edge i near to Paris (idem for tokyo : j) i = SommetPlusProche(lat1,lon1,S) j = SommetPlusProche(lat2,lon2,S) // Shortest Path algorithmes [FD,FP] = AlgoFloyd(D); [DD,DP] = AlgoDijkstra(D,i); // To get the path : CF = Geodesique(FP(i,:),j); // use Floyd result CD = Geodesique(DP,j); // use Dijkstra result // To draw the shortest path on the graph... What doesn't work well! TraceChemin(CF,2,5,5);