source: trunk/MagicSoft/slalib/dpav.c@ 5899

Last change on this file since 5899 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3double slaDpav ( double v1 [ 3 ], double v2 [ 3 ] )
4/*
5** - - - - - - - -
6** s l a D p a v
7** - - - - - - - -
8**
9** Position angle of one celestial direction with respect to another.
10**
11** (double precision)
12**
13** Given:
14** v1 double[3] direction cosines of one point
15** v2 double[3] direction cosines of the other point
16**
17** (The coordinate frames correspond to RA,Dec, Long,Lat etc.)
18**
19** The result is the bearing (position angle), in radians, of point
20** v2 with respect to point v1. It is in the range +/- pi. The
21** sense is such that if v2 is a small distance east of v1, the
22** bearing is about +pi/2. Zero is returned if the two points
23** are coincident.
24**
25** The vectors v1 and v2 need not be unit vectors.
26**
27** The routine slaDbear performs an equivalent function except
28** that the points are specified in the form of spherical
29** coordinates.
30**
31** Last revision: 12 December 1996
32**
33** Copyright P.T.Wallace. All rights reserved.
34*/
35{
36 double x0, y0, z0, w, x1, y1, z1, s, c;
37
38
39/* Unit vector to point 1. */
40 x0 = v1 [ 0 ];
41 y0 = v1 [ 1 ];
42 z0 = v1 [ 2 ];
43 w = sqrt ( x0 * x0 + y0 * y0 + z0 * z0 );
44 if ( w != 0.0 ) { x0 /= w; y0 /= w; z0 /= w; }
45
46/* Vector to point 2. */
47 x1 = v2 [ 0 ];
48 y1 = v2 [ 1 ];
49 z1 = v2 [ 2 ];
50
51/* Position angle. */
52 s = y1 * x0 - x1 * y0;
53 c = z1 * ( x0 * x0 + y0 * y0 ) - z0 * ( x1 * x0 + y1 * y0 );
54 return ( s != 0.0 || c != 0.0 ) ? atan2 ( s, c ) : 0.0;
55}
Note: See TracBrowser for help on using the repository browser.