1 | #include "slalib.h"
|
---|
2 | #include "slamac.h"
|
---|
3 | void slaDe2h ( double ha, double dec, double phi, double *az, double *el )
|
---|
4 | /*
|
---|
5 | ** - - - - - - - -
|
---|
6 | ** s l a D e 2 h
|
---|
7 | ** - - - - - - - -
|
---|
8 | **
|
---|
9 | ** Equatorial to horizon coordinates: HA,Dec to Az,El
|
---|
10 | **
|
---|
11 | ** (double precision)
|
---|
12 | **
|
---|
13 | ** Given:
|
---|
14 | ** ha double hour angle
|
---|
15 | ** dec double declination
|
---|
16 | ** phi double observatory latitude
|
---|
17 | **
|
---|
18 | ** Returned:
|
---|
19 | ** *az double azimuth
|
---|
20 | ** *el double elevation
|
---|
21 | **
|
---|
22 | ** Notes:
|
---|
23 | **
|
---|
24 | ** 1) All the arguments are angles in radians.
|
---|
25 | **
|
---|
26 | ** 2) Azimuth is returned in the range 0-2pi; north is zero,
|
---|
27 | ** and east is +pi/2. Elevation is returned in the range
|
---|
28 | ** +/-pi/2.
|
---|
29 | **
|
---|
30 | ** 3) The latitude must be geodetic. In critical applications,
|
---|
31 | ** corrections for polar motion should be applied.
|
---|
32 | **
|
---|
33 | ** 4) In some applications it will be important to specify the
|
---|
34 | ** correct type of hour angle and declination in order to
|
---|
35 | ** produce the required type of azimuth and elevation. In
|
---|
36 | ** particular, it may be important to distinguish between
|
---|
37 | ** elevation as affected by refraction, which would
|
---|
38 | ** require the "observed" HA,Dec, and the elevation
|
---|
39 | ** in vacuo, which would require the "topocentric" HA,Dec.
|
---|
40 | ** If the effects of diurnal aberration can be neglected, the
|
---|
41 | ** "apparent" HA,Dec may be used instead of the topocentric
|
---|
42 | ** HA,Dec.
|
---|
43 | **
|
---|
44 | ** 5) No range checking of arguments is carried out.
|
---|
45 | **
|
---|
46 | ** 6) 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, and (for tracking a star)
|
---|
50 | ** sine and cosine of declination.
|
---|
51 | **
|
---|
52 | ** Defined in slamac.h: D2PI
|
---|
53 | **
|
---|
54 | ** Last revision: 10 July 1994
|
---|
55 | **
|
---|
56 | ** Copyright P.T.Wallace. All rights reserved.
|
---|
57 | */
|
---|
58 | {
|
---|
59 | double sh, ch, sd, cd, sp, cp, x, y, z, r, a;
|
---|
60 |
|
---|
61 | /* Useful trig functions */
|
---|
62 | sh = sin ( ha );
|
---|
63 | ch = cos ( ha );
|
---|
64 | sd = sin ( dec );
|
---|
65 | cd = cos ( dec );
|
---|
66 | sp = sin ( phi );
|
---|
67 | cp = cos ( phi );
|
---|
68 |
|
---|
69 | /* Az,El as x,y,z */
|
---|
70 | x = - ch * cd * sp + sd * cp;
|
---|
71 | y = - sh * cd;
|
---|
72 | z = ch * cd * cp + sd * sp;
|
---|
73 |
|
---|
74 | /* To spherical */
|
---|
75 | r = sqrt ( x * x + y * y );
|
---|
76 | a = ( r == 0.0 ) ? 0.0 : atan2 ( y, x ) ;
|
---|
77 | *az = ( a < 0.0 ) ? a + D2PI : a;
|
---|
78 | *el = atan2 ( z, r );
|
---|
79 | }
|
---|