1function [geodesic, aux] = geodesicinverse(latlong, a, f)
2%GEODESICINVERSE  Wrapper for geoddistance
3%
4%   [geodesic, aux] = GEODESICINVERSE(latlong)
5%   [geodesic, aux] = GEODESICINVERSE(latlong, a, f)
6%
7%   This is a legacy function to replace a compiled interface function of
8%   the same name.  This now calls geoddistance which is implemented as
9%   native Matlab code.
10%
11%   latlong is an M x 4 matrix
12%       latitude of point 1 = latlong(:,1) in degrees
13%       longitude of point 1 = latlong(:,2) in degrees
14%       latitude of point 2 = latlong(:,3) in degrees
15%       longitude of point 2 = latlong(:,4) in degrees
16%
17%   geodesic is an M x 3 matrix
18%       azimuth at point 1 = geodesic(:,1) in degrees
19%       azimuth at point 2 = geodesic(:,2) in degrees
20%       distance between points 1 and 2 = geodesic(:,3) in meters
21%   aux is an M x 5 matrix
22%       spherical arc length = aux(:,1) in degrees
23%       reduced length = aux(:,2) in meters
24%       geodesic scale 1 to 2 = aux(:,3)
25%       geodesic scale 2 to 1 = aux(:,4)
26%       area under geodesic = aux(:,5) in meters^2
27%
28%   a = equatorial radius (meters)
29%   f = flattening (0 means a sphere)
30%   If a and f are omitted, the WGS84 values are used.
31%
32%   See also GEODDISTANCE.
33
34% Copyright (c) Charles Karney (2015-2017) <charles@karney.com>.
35
36  if (nargin < 2)
37    ellipsoid = defaultellipsoid;
38  elseif (nargin < 3)
39    ellipsoid = [a, 0];
40  else
41    ellipsoid = [a, flat2ecc(f)];
42  end
43  [s12, azi1, azi2, S12, m12, M12, M21, a12] = geoddistance ...
44      (latlong(:,1), latlong(:,2), latlong(:,3), latlong(:,4), ellipsoid);
45  geodesic = [azi1, azi2, s12];
46  aux = [a12, m12, M12, M21, S12];
47end
48