| 1 | #include "slalib.h"
|
|---|
| 2 | #include "slamac.h"
|
|---|
| 3 | void slaE2h ( float ha, float dec, float phi, float *az, float *el )
|
|---|
| 4 | /*
|
|---|
| 5 | ** - - - - - - -
|
|---|
| 6 | ** s l a E 2 h
|
|---|
| 7 | ** - - - - - - -
|
|---|
| 8 | **
|
|---|
| 9 | ** Equatorial to horizon coordinates: HA,Dec to Az,El
|
|---|
| 10 | **
|
|---|
| 11 | ** (single precision)
|
|---|
| 12 | **
|
|---|
| 13 | ** Given:
|
|---|
| 14 | ** ha float hour angle
|
|---|
| 15 | ** dec float declination
|
|---|
| 16 | ** phi float observatory latitude
|
|---|
| 17 | **
|
|---|
| 18 | ** Returned:
|
|---|
| 19 | ** *az float azimuth
|
|---|
| 20 | ** *el float 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 | float sh, ch, sd, cd, sp, cp, x, y, z, r, a;
|
|---|
| 60 |
|
|---|
| 61 | /* Useful trig functions */
|
|---|
| 62 | sh = (float) sin ( ha );
|
|---|
| 63 | ch = (float) cos ( ha );
|
|---|
| 64 | sd = (float) sin ( dec );
|
|---|
| 65 | cd = (float) cos ( dec );
|
|---|
| 66 | sp = (float) sin ( phi );
|
|---|
| 67 | cp = (float) 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 = (float) sqrt ( x * x + y * y );
|
|---|
| 76 | a = ( r == 0.0f ) ? 0.0f : (float) atan2 ( y, x ) ;
|
|---|
| 77 | *az = ( a < 0.0f ) ? (float) ( (double) a + D2PI ) : a;
|
|---|
| 78 | *el = (float) atan2 ( z, r );
|
|---|
| 79 | }
|
|---|