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

Last change on this file since 3887 was 3654, checked in by cmv, 16 years ago

mise a niveau Xephem 3.7.4, cmv 16/07/2009

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