source: Sophya/trunk/SophyaExt/XephemAstroLib/aa_hadec.c@ 2437

Last change on this file since 2437 was 1719, checked in by cmv, 24 years ago

Adapted to version 3.5 xephem cmv 22/10/2001

File size: 1.8 KB
Line 
1/* function to convert between alt/az and ha/dec.
2 */
3
4#include <stdio.h>
5#include <math.h>
6
7#include "P_.h"
8#include "astro.h"
9
10static void aaha_aux P_((double lat, double x, double y, double *p, double *q));
11
12/* given geographical latitude (n+, radians), lat, altitude (up+, radians),
13 * alt, and azimuth (angle round to the east from north+, radians),
14 * return hour angle (radians), ha, and declination (radians), dec.
15 */
16void
17aa_hadec (lat, alt, az, ha, dec)
18double lat;
19double alt, az;
20double *ha, *dec;
21{
22 aaha_aux (lat, az, alt, ha, dec);
23 if (*ha > PI)
24 *ha -= 2*PI;
25}
26
27/* given geographical (n+, radians), lat, hour angle (radians), ha, and
28 * declination (radians), dec, return altitude (up+, radians), alt, and
29 * azimuth (angle round to the east from north+, radians),
30 */
31void
32hadec_aa (lat, ha, dec, alt, az)
33double lat;
34double ha, dec;
35double *alt, *az;
36{
37 aaha_aux (lat, ha, dec, az, alt);
38}
39
40#ifdef NEED_GEOC
41/* given a geographic (surface-normal) latitude, phi, return the geocentric
42 * latitude, psi.
43 */
44double
45geoc_lat (phi)
46double phi;
47{
48#define MAXLAT degrad(89.9999) /* avoid tan() greater than this */
49 return (fabs(phi)>MAXLAT ? phi : atan(tan(phi)/1.00674));
50}
51#endif
52
53/* the actual formula is the same for both transformation directions so
54 * do it here once for each way.
55 * N.B. all arguments are in radians.
56 */
57static void
58aaha_aux (lat, x, y, p, q)
59double lat;
60double x, y;
61double *p, *q;
62{
63 static double last_lat = -3434, slat, clat;
64 double cap, B;
65
66 if (lat != last_lat) {
67 slat = sin(lat);
68 clat = cos(lat);
69 last_lat = lat;
70 }
71
72 solve_sphere (-x, PI/2-y, slat, clat, &cap, &B);
73 *p = B;
74 *q = PI/2 - acos(cap);
75}
76
77/* For RCS Only -- Do Not Edit */
78static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: aa_hadec.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
Note: See TracBrowser for help on using the repository browser.