# Documentation

## Directions and Areas on the Sphere and Spheroid

Azimuth is the angle a line makes with a meridian, measured clockwise from north. Thus the azimuth of due north is 0º, due east is 90º, due south is 180º, and due west is 270º. You can instruct several Mapping Toolbox™ functions to compute azimuths for any pair of point locations, either along rhumb lines or along great circles. These will have different results except along cardinal directions. For great circles, the result is the azimuth at the initial point of the pair defining a great circle path. This is because great circle azimuths other than 0º, 90º, 180º, and 270º do not remain constant. Azimuths for rhumb lines are constant along their entire path (by definition).

For rhumb lines, computing an azimuth backward (from the second point to the first) yields the complement of the forward azimuth ((Az + 180º) mod 360º). For great circles, the back azimuth is generally not the complement, and the difference depends on the distance between the two points.

In addition to forward and back azimuths, Mapping Toolbox functions can compute locations of points a given distance and azimuth from a reference point, and can calculate tracks to connect waypoints, along either great circles or rhumb lines on a sphere or ellipsoid.

### Reckoning — The Forward Problem

A common problem in geographic applications is the determination of a destination given a starting point, an initial azimuth, and a distance. In the toolbox, this process is called reckoning. A new position can be reckoned in a great circle or a rhumb line sense (great circle or rhumb line track).

As an example, an airplane takes off from La Guardia Airport in New York (40.75ºN, 73.9ºW) and follows a northwestern rhumb line flight path at 200 knots (nautical miles per hour). Where would it be after 1 hour?

```[rhlat,rhlong] = reckon('rh',40.75,-73.9,nm2deg(200),315) rhlat = 43.1054 rhlong = -77.0665```

Notice that the distance, 200 nautical miles, must be converted to degrees of arc length with the `nm2deg` conversion function to match the latitude and longitude inputs. If the airplane had a flight computer that allowed it to follow an exact great circle path, what would the aircraft's new location be?

```[gclat,gclong] = reckon('gc',40.75,-73.9,nm2deg(200),315) gclat = 43.0615 gclong = -77.1238```

Notice also that for short distances at these latitudes, the result hardly differs between great circle and rhumb line. The two destination points are less than 4 nautical miles apart. Incidentally, after 1 hour, the airplane would be just north of New York's Finger Lakes.

#### Calculating Tracks — Great Circles and Rhumb Lines

You can generate vector data corresponding to points along great circle or rhumb line tracks using `track1` and `track2`. If you have a point on the track and an azimuth at that point, use `track1`. If you have two points on the track, use `track2`. For example, to get the great circle path starting at (31ºS, 90ºE) with an azimuth of 45º with a length of 12º, use `track1`:

`[latgc,longc] = track1('gc',-31,90,45,12);`

For the great circle from (31ºS, 90ºE) to (23ºS, 110ºE), use `track2`:

`[latgc,longc] = track2('gc',-31,90,-23,110);`

The `track1` function also allows you to specify range endpoints. For example, if you want points along a rhumb line starting 5º away from the initial point and ending 13º away, at an azimuth of 55º, simply specify the range limits:

`[latrh,lonrh] = track1('rh',-31,90,55,[5 13]);`

When no range is provided for `track1`, the returned points represent a complete track. For great circles, a complete track is 360º, encircling the planet and returning to the initial point. For rhumb lines, the complete track terminates at the poles, unless the azimuth is 90º or 270º, in which case the complete track is a parallel that returns to the initial point.

For calculated tracks, 100 points are returned unless otherwise specified. You can calculate several tracks at one time by providing vector inputs. For more information, see the `track1` and `track2` reference pages. More vector path calculations are described later in Navigation.

### Distance, Azimuth, and Back-Azimuth (the Inverse Problem)

When Mapping Toolbox functions calculate the distance between two points in geographic space, the result depends upon whether you specify great circle or rhumb line distance. The `distance` function returns the appropriate distance between two points as an angular arc length, employing the same angular units as the input latitudes and longitudes. The default path type is the shorter great circle, and the default angular units are degrees. The previous figure shows two points at (15ºS, 0º) and (60ºN, 150ºE). The great circle distance between them, in degrees of arc, is as follows:

```distgc = distance(-15,0,60,150) distgc = 129.9712```

The rhumb line distance is greater:

```distrh = distance('rh',-15,0,60,150) distrh = 145.0288```

To determine how much longer the rhumb line path is in, say, kilometers, you can use a distance conversion function on the difference:

```kmdifference = deg2km(distrh-distgc) kmdifference = 1.6744e+03```

Several distance conversion functions are available in the toolbox, supporting degrees, radians, kilometers, meters, statute miles, nautical miles, and feet. Converting distances between angular arc length units and surface length units requires the radius of a planet or spheroid. By default, the radius of the Earth is used.

#### Calculating Azimuth and Elevation

Azimuth is the angle a line makes with a meridian, taken clockwise from north. When the azimuth is calculated from one point to another using the toolbox, the result depends upon whether you want a great circle or a rhumb line azimuth. For great circles, the result is the azimuth at the starting point of the connecting great circle path. In general, the azimuth along a great circle is not constant. For rhumb lines, the resulting azimuth is constant along the entire path.

Azimuths, or bearings, are returned in the same angular units as the input latitudes and longitudes. The default path type is the shorter great circle, and the default angular units are degrees. In the example, the great circle azimuth from the first point to the second is

```azgc = azimuth(-15,0,60,150) azgc = 19.0391```

For the rhumb line, the constant azimuth is

```azrh = azimuth('rh',-15,0,60,150) azrh = 58.8595```

One feature of rhumb lines is that the inverse azimuth, from the second point to the first, is the complement of the forward azimuth and can be calculated by simply adding 180º to the forward value:

```inverserh = azimuth('rh',60,150,-15,0) inverserh = 238.8595 difference = inverserh-azrh difference = 180```

This is not true, in general, of great circles:

```inversegc = azimuth('gc',60,150,-15,0) inversegc = 320.9353 difference = inversegc-azgc difference = 301.8962```

The azimuths associated with cardinal and intercardinal compass directions are the following:

 North 0º or 360º Northeast 45º East 90º Southeast 135º South 180º Southwest 225º West 270º Northwest 315º

Elevation is the angle above the local horizontal of one point relative to the other. To compute the elevation angle of a second point as viewed from the first, provide the position and altitude of the points. The default units are degrees for latitudes and longitudes and meters for altitudes, but you can specify other units for each. What are the elevation, slant range, and azimuth of a point 10 kilometers east and 10 kilometers above a surface point?

```[elevang,slantrange,azim] = elevation(0,0,0,0,km2deg(10),10000) elevang = 44.9005 slantrange = 1.4156e+004 azim = 90```

On an ellipsoid, azimuths returned from `elevation` generally will differ from those returned by `azimuth` and `distance`.

### Measuring Area of Spherical Quadrangles

In solid geometry, the area of a spherical quadrangle can be exactly calculated. A spherical quadrangle is the intersection of a lune and a zone. In geographic terms, a quadrangle is defined as a region bounded by parallels north and south, and meridians east and west.

In the pictured example, a quadrangle is formed by the intersection of a zone, which is the region bounded by 15ºN and 45ºN latitudes, and a lune, which is the region bounded by 0º and 30ºE longitude. Under the spherical planet assumption, the fraction of the entire spherical surface area inscribed in the quadrangle can be calculated:

```area = areaquad(15,0,45,30) area = 0.0187```

That is, less than 2% of the planet's surface area is in this quadrangle. To get an absolute figure in, for example, square miles, you must provide the appropriate spherical radius. The radius of the Earth is about 3958.9 miles:

```area = areaquad(15,0,45,30,3958.9) area = 3.6788e+06```

The surface area within this quadrangle is over 3.6 million square miles for a spherical Earth.

Get trial now