| Mapping Toolbox | ![]() |
Compute great circle or rhumb line track defined by two points
Syntax
[lattrk,lontrk] = track2(lat1,lon1,lat2,lon2) [lattrk,lontrk] = track2(track,lat1,lon1,lat2,lon2) [lattrk,lontrk] = track2(track,lat1,lon1,lat2,lon2,units) [lattrk,lontrk] = track2(track,lat1,lon1,lat2,lon2,geoid) [lattrk,lontrk] = track2(track,lat1,lon1,lat2,lon2,geoid,units) [lattrk,lontrk] = track2(lat1,lon1,lat2,lon2,geoid,units,npts) pts = track2(lat1,lon1,lat2,lon2)
Background
A path along the surface of the Earth connecting two points is a track. Two types of track lines are of interest geographically, great circles and rhumb lines. Great circles represent the shortest possible path between two points. Rhumb lines are paths with constant angular headings. They are not, in general, the shortest path between two points.
Description
[lattrk,lontrk] = track2(lat1,lon1,lat2,lon2) returns, in lattrk and lontrk, points along a (great circle) track between the points specified by lat1 with lon1 and lat2 and lon2. When the inputs are column vectors, the successive tracks are stored in separate columns of lattrk and lontrk.
[lattrk,lontrk] = track2(track,lat1,lon1,lat2,lon2) allows the specification of the track logic to be employed. A string track of 'gc' is the default, resulting in a great circle track. A track of 'rh' results in a rhumb line track.
[lattrk,lontrk] = track2(track,lat1,lon1,lat2,lon2,units) specifies the units of the inputs and outputs, where units is any valid angle unit string. The default is 'degrees'.
[lattrk,lontrk] = track2(track,lat1,lon1,lat2,lon2,geoid,units) specifies the elliptical definition of the Earth with a two-element geoid model vector geoid. The default geoid is a spherical Earth, which is sufficient for most applications.
[lattrk,lontrk] = track2(lat1,lon1,lat2,lon2,geoid,units,npts) specifies the number of points, npts, per output track. npts is 100 by default.
pts = track2(lat1,lon1,lat2,lon2,...) combines the outputs into a single, two-column matrix pts.
Example
axesm('mercator','MapLatLimit',[30 50],'MapLonLimit',[-40 40]) [lattrkgc,lontrkgc] = track2(40,-35,40,35); [lattrkrh,lontrkrh] = track2('rh',40,-35,40,35); plotm(lattrkgc,lontrkgc,'g') plotm(lattrkrh,lontrkrh,'r')
See Also
azimuth |
Azimuth between two points on the globe |
distance |
Distance between two points on the globe |
reckon |
New point with an azimuth and distance |
scircle1scircle2 |
Small circle coordinates |
track |
Connect waypoints with track segments |
track1 |
Great circle or rhumb line from point and azimuth |
trackg |
Interactive tracks |
| track1 | trackg | ![]() |