# gcwaypts

Equally spaced waypoints along great circle

## Syntax

`[lat,lon] = gcwaypts(lat1,lon1,lat2,lon2)[lat,lon] = gcwaypts(lat1,lon1,lat2,lon2,nlegs)pts = gcwaypts(lat1,lon1,lat2,lon2...)`

## Description

`[lat,lon] = gcwaypts(lat1,lon1,lat2,lon2)` returns the coordinates of equally spaced points along a great circle path connecting two endpoints, (`lat1,lon1`) and (`lat2,lon2`).

`[lat,lon] = gcwaypts(lat1,lon1,lat2,lon2,nlegs)` specifies the number of equal-length track legs to calculate. `nlegs+1` output points are returned, since a final endpoint is required. The default number of legs is 10.

`pts = gcwaypts(lat1,lon1,lat2,lon2...)` packs the outputs, which are otherwise two-column vectors, into a two-column matrix of the form `[latitude longitude]`. This format for successive waypoints along a navigational track is called navigational track format in this guide. See the `navigational track format` reference page in this section for more information.

## Background

This is a navigational function. It assumes that all latitudes and longitudes are in degrees.

In navigational practice, great circle paths are often approximated by rhumb line segments. This is done to come reasonably close to the shortest distance between points without requiring course changes too frequently. The `gcwaypts` function provides an easy means of finding waypoints along a great circle path that can serve as endpoints for rhumb line segments (track legs).

## Examples

Imagine you own a sailing yacht and are planning a voyage from North Point, Barbados (13.33º N,59.62ºW), to Brest, France (48.36ºN,4.49ºW). To divide the track into three equal-length segments,

```figure('color','w'); ha = axesm('mapproj','mercator',... 'maplatlim',[10 55],'maplonlim',[-80 10],... 'MLineLocation',15,'PLineLocation',15); axis off, gridm on, framem on; load coast; hg = geoshow(lat,long,'displaytype','line','color','b'); % Define point locations for Barbados and Brest barbados = [13.33 -59.62]; brest = [48.36 -4.49]; [l,g] = gcwaypts(barbados(1),barbados(2),brest(1),brest(2),3); geoshow(l,g,'displaytype','line','color','r',... 'markeredgecolor','r','markerfacecolor','r','marker','o'); geoshow(barbados(1),barbados(2),'DisplayType','point',... 'markeredgecolor','k','markerfacecolor','k','marker','o') geoshow(brest(1),brest(2),'DisplayType','point',... 'markeredgecolor','k','markerfacecolor','k','marker','o') ```