source: trunk/MagicSoft/slalib/h2e.c@ 16327

Last change on this file since 16327 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaH2e ( float az, float el, float phi, float *ha, float *dec )
4/*
5** - - - - - - -
6** s l a H 2 e
7** - - - - - - -
8**
9** Horizon to equatorial coordinates: Az,El to HA,Dec
10**
11** (single precision)
12**
13** Given:
14** az float azimuth
15** el float elevation
16** phi float observatory latitude
17**
18** Returned:
19** *ha float hour angle
20** *dec float 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 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 float sa, ca, se, ce, sp, cp, x, y, z, r;
57
58/* Useful trig functions */
59 sa = (float) sin ( az );
60 ca = (float) cos ( az );
61 se = (float) sin ( el );
62 ce = (float) cos ( el );
63 sp = (float) sin ( phi );
64 cp = (float) 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 = (float) sqrt ( x * x + y * y );
73 *ha = ( r == 0.0f ) ? 0.0f : (float) atan2 ( y, x ) ;
74 *dec = (float) atan2 ( z, r );
75}
Note: See TracBrowser for help on using the repository browser.