source: trunk/MagicSoft/slalib/dbear.c@ 807

Last change on this file since 807 was 731, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3double slaDbear ( double a1, double b1, double a2, double b2 )
4/*
5** - - - - - - - - -
6** s l a D b e a r
7** - - - - - - - - -
8**
9** Bearing (position angle) of one point on a sphere relative
10** to another.
11**
12** (double precision)
13**
14** Given:
15** a1,b1 double spherical coordinates of one point
16** a2,b2 double spherical coordinates of the other point
17**
18** (The spherical coordinates are RA,Dec, Long,Lat etc, in radians.)
19**
20** The result is the bearing (position angle), in radians, of point
21** a2,b2 as seen from point a1,b1. It is in the range +/- pi. The
22** sense is such that if a2,b2 is a small distance east of a1,b1,
23** the bearing is about +pi/2. Zero is returned if the two points
24** are coincident.
25**
26** If either b-coordinate is outside the range +/- pi/2, the
27** result may correspond to "the long way round".
28**
29** The routine slaDpav performs an equivalent function except
30** that the points are specified in the form of Cartesian unit
31** vectors.
32**
33** Last revision: 8 December 1996
34**
35** Copyright P.T.Wallace. All rights reserved.
36*/
37{
38 double da, x, y;
39
40 da = a2 - a1;
41 y = sin ( da ) * cos ( b2 );
42 x = sin ( b2 ) * cos ( b1 ) - cos ( b2 ) * sin ( b1 ) * cos ( da );
43 return ( x != 0.0 || y != 0.0 ) ? atan2 ( y, x ) : 0.0;
44}
Note: See TracBrowser for help on using the repository browser.