Courses and distances between navigational waypoints
[course,dist] = legs(lat,lon)
[course,dist] = legs(lat,lon,method)
[course,dist] = legs(pts) and [course,dist] = legs(pts,method)
mat = legs(lat,...)
[course,dist] = legs(lat,lon,method) specifies the logic for the leg characteristics. If the string method is 'rh' (the default), course and dist are calculated in a rhumb line sense. If method is 'gc', great circle calculations are used.
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.
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.4960
Upon 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+003
For a great circle route,
[coursegc,distgc] = legs(lat,long,'gc'); totalgc = sum(distgc) totalgc = 2.2451e+003
The great circle path is less than one-half of one percent shorter.