1 ## Copyright (C) 2004 Andrew Collier <abcollier@users.sourceforge.net>
3 ## This program is free software; it is distributed in the hope that it
4 ## will be useful, but WITHOUT ANY WARRANTY; without even the implied
5 ## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
6 ## the GNU General Public License for more details.
8 ## You should have received a copy of the GNU General Public License
9 ## along with this file; see the file COPYING. If not, see
10 ## <http://www.gnu.org/licenses/>.
13 ## @deftypefn {Function File} {} @var{dist} = distance(@var{pt1}, @var{pt2})
15 ## Calculates the distance (in degrees) between @var{pt1} and @var{pt2}.
17 ## @var{pt1} and @var{pt2} are two-column matrices of the form [latitude longitude].
20 ## >> distance([37,-76], [37,-9])
22 ## >> distance([37,-76], [67,-76])
26 ## @seealso{azimuth,elevation}
29 ## Author: Andrew Collier <abcollier@users.sourceforge.net>
31 ## Uses "cosine formula".
33 function dist = distance(pt1, pt2)
41 dist = rad2deg(acos(cos(b) * cos(c) + sin(b) * sin(c) * cos(A)));
44 ## http://www.mathworks.com/access/helpdesk/help/toolbox/map/distance.shtml