source: trunk/MagicSoft/slalib/dh2e.c@ 9212

Last change on this file since 9212 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaDh2e ( double az, double el, double phi, double *ha, double *dec )
4/*
5** - - - - - - - -
6** s l a D h 2 e
7** - - - - - - - -
8**
9** Horizon to equatorial coordinates: Az,El to HA,Dec
10**
11** (double precision)
12**
13** Given:
14** az double azimuth
15** el double elevation
16** phi double observatory latitude
17**
18** Returned:
19** *ha double hour angle
20** *dec double declination
21**
22** Notes:
23**
24** 1) All the arguments are angles in radians.
25**
26** 2) The sign convention for azimuth is north zero, east +pi/2.
27**
28** 3) HA is returned in the range +/-pi. Declination is returned
29** in the range +/-pi/2.
30**
31** 4) The is latitude is (in principle) geodetic. In critical
32** applications, corrections for polar motion should be applied.
33**
34** 5) In some applications it will be important to specify the
35** correct type of elevation in order to produce the required
36** type of HA,Dec. In particular, it may be important to
37** distinguish between the elevation as affected by refraction,
38** which will yield the "observed" HA,Dec, and the elevation
39** in vacuo, which will yield the "topocentric" HA,Dec. If the
40** effects of diurnal aberration can be neglected, the
41** topocentric HA,Dec may be used as an approximation to the
42** "apparent" HA,Dec.
43**
44** 6) No range checking of arguments is done.
45**
46** 7) In applications which involve many such calculations, rather
47** than calling the present routine it will be more efficient to
48** use inline code, having previously computed fixed terms such
49** as sine and cosine of latitude.
50**
51** Last revision: 21 February 1996
52**
53** Copyright P.T.Wallace. All rights reserved.
54*/
55{
56 double sa, ca, se, ce, sp, cp, x, y, z, r;
57
58/* Useful trig functions */
59 sa = sin ( az );
60 ca = cos ( az );
61 se = sin ( el );
62 ce = cos ( el );
63 sp = sin ( phi );
64 cp = cos ( phi );
65
66/* HA,Dec as x,y,z */
67 x = - ca * ce * sp + se * cp;
68 y = - sa * ce;
69 z = ca * ce * cp + se * sp;
70
71/* To spherical */
72 r = sqrt ( x * x + y * y );
73 *ha = ( r == 0.0 ) ? 0.0 : atan2 ( y, x ) ;
74 *dec = atan2 ( z, r );
75}
Note: See TracBrowser for help on using the repository browser.