legs
Courses and distances between navigational waypoints
Syntax
[course,dist] = legs(lat,lon)
[course,dist] = legs(lat,lon,method)
[course,dist] = legs(pts,___)
mat = legs(___)
Description
[course,dist] = legs(lat,lon) returns
the azimuths (course) and distances (dist)
between navigational waypoints, which are specified by the column
vectors lat and lon.
[course,dist] = legs(lat,lon,method) specifies
the logic for the leg characteristics. If the method is 'rh' (the
default), course and dist are
calculated in a rhumb line sense. If method is 'gc',
great circle calculations are used.
[course,dist] = legs(pts,___) specifies
waypoints in a single two-column matrix, pts.
mat = legs(___) packs
up the outputs into a single two-column matrix, mat.
This is a navigation function. All angles are in degrees, and all distances are in nautical miles. Track legs are the courses and distances traveled between navigational waypoints.
Examples
Imagine an airplane taking off from Logan International Airport in Boston (42.3ºN,71ºW) and traveling to LAX in Los Angeles (34ºN,118ºW). The pilot wants to file a flight plan that takes the plane over O'Hare Airport in Chicago (42ºN,88ºW) for a navigational update, while maintaining a constant heading on each of the two legs of the trip.
What are those headings and how long are the legs?
lat = [42.3; 42; 34];
long = [-71; -88; -118];
[course,dist] = legs(lat,long,'rh')
course =
268.6365
251.2724
dist =
1.0e+003 *
0.7569
1.4960Upon takeoff, the plane should proceed on a heading of about 269º for 756 nautical miles, then alter course to 251º for another 1495 miles.
How much farther is it traveling by not following a great circle path between waypoints? Using rhumb lines, it is traveling
totalrh = sum(dist)
totalrh =
2.2530e+003For a great circle route,
[coursegc,distgc] = legs(lat,long,'gc'); totalgc = sum(distgc)
totalgc =
2.2451e+003The great circle path is less than one-half of one percent shorter.