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

Last change on this file since 4060 was 4017, checked in by cmv, 14 years ago

fichiers de Xephem 3.7.5 update, cmv 21/09/2011

File size: 1.8 KB
RevLine 
[1457]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
[2551]9static void aaha_aux (double lt, double x, double y, double *p, double *q);
[1457]10
[2551]11/* given geographical latitude (n+, radians), lt, altitude (up+, radians),
[1457]12 * alt, and azimuth (angle round to the east from north+, radians),
13 * return hour angle (radians), ha, and declination (radians), dec.
14 */
15void
[2551]16aa_hadec (
17double lt,
18double alt, double az,
19double *ha, double *dec)
[1457]20{
[2551]21 aaha_aux (lt, az, alt, ha, dec);
[1457]22 if (*ha > PI)
23 *ha -= 2*PI;
24}
25
[2551]26/* given geographical (n+, radians), lt, hour angle (radians), ha, and
[1457]27 * declination (radians), dec, return altitude (up+, radians), alt, and
28 * azimuth (angle round to the east from north+, radians),
29 */
30void
[2551]31hadec_aa (
32double lt,
33double ha, double dec,
34double *alt, double *az)
[1457]35{
[2551]36 aaha_aux (lt, ha, dec, az, alt);
[1457]37}
38
39#ifdef NEED_GEOC
40/* given a geographic (surface-normal) latitude, phi, return the geocentric
41 * latitude, psi.
42 */
43double
[2551]44geoc_lat (
45double phi)
[1457]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
[2551]57aaha_aux (
58double lt,
59double x, double y,
60double *p, double *q)
[1457]61{
[2551]62 static double last_lt = -3434, slt, clt;
[1457]63 double cap, B;
64
[2551]65 if (lt != last_lt) {
66 slt = sin(lt);
67 clt = cos(lt);
68 last_lt = lt;
[1457]69 }
70
[2551]71 solve_sphere (-x, PI/2-y, slt, clt, &cap, &B);
[1457]72 *p = B;
73 *q = PI/2 - acos(cap);
74}
75
76/* For RCS Only -- Do Not Edit */
[4017]77static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: aa_hadec.c,v $ $Date: 2011-09-21 16:17:47 $ $Revision: 1.9 $ $Name: not supported by cvs2svn $"};
Note: See TracBrowser for help on using the repository browser.