| [1457] | 1 | #include <stdio.h>
 | 
|---|
 | 2 | #include <math.h>
 | 
|---|
 | 3 | 
 | 
|---|
 | 4 | #include "P_.h"
 | 
|---|
 | 5 | #include "astro.h"
 | 
|---|
 | 6 | 
 | 
|---|
 | 7 | static void ecleq_aux P_((int sw, double mjd, double x, double y,
 | 
|---|
 | 8 |     double *p, double *q));
 | 
|---|
 | 9 | 
 | 
|---|
 | 10 | #define EQtoECL 1
 | 
|---|
 | 11 | #define ECLtoEQ (-1)
 | 
|---|
 | 12 | 
 | 
|---|
 | 13 | 
 | 
|---|
 | 14 | /* given the modified Julian date, mjd, and an equitorial ra and dec, each in
 | 
|---|
 | 15 |  * radians, find the corresponding geocentric ecliptic latitude, *lat, and
 | 
|---|
 | 16 |  * longititude, *lng, also each in radians.
 | 
|---|
 | 17 |  * correction for the effect on the angle of the obliquity due to nutation is
 | 
|---|
 | 18 |  * not included.
 | 
|---|
 | 19 |  */
 | 
|---|
 | 20 | void
 | 
|---|
 | 21 | eq_ecl (mjd, ra, dec, lat, lng)
 | 
|---|
 | 22 | double mjd;
 | 
|---|
 | 23 | double ra, dec;
 | 
|---|
 | 24 | double *lat, *lng;
 | 
|---|
 | 25 | {
 | 
|---|
 | 26 |         ecleq_aux (EQtoECL, mjd, ra, dec, lng, lat);
 | 
|---|
 | 27 | }
 | 
|---|
 | 28 | 
 | 
|---|
 | 29 | /* given the modified Julian date, mjd, and a geocentric ecliptic latitude,
 | 
|---|
 | 30 |  * *lat, and longititude, *lng, each in radians, find the corresponding
 | 
|---|
 | 31 |  * equitorial ra and dec, also each in radians.
 | 
|---|
 | 32 |  * correction for the effect on the angle of the obliquity due to nutation is
 | 
|---|
 | 33 |  * not included.
 | 
|---|
 | 34 |  */
 | 
|---|
 | 35 | void
 | 
|---|
 | 36 | ecl_eq (mjd, lat, lng, ra, dec)
 | 
|---|
 | 37 | double mjd;
 | 
|---|
 | 38 | double lat, lng;
 | 
|---|
 | 39 | double *ra, *dec;
 | 
|---|
 | 40 | {
 | 
|---|
 | 41 |         ecleq_aux (ECLtoEQ, mjd, lng, lat, ra, dec);
 | 
|---|
 | 42 | }
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | static void
 | 
|---|
 | 45 | ecleq_aux (sw, mjd, x, y, p, q)
 | 
|---|
 | 46 | int sw;                 /* +1 for eq to ecliptic, -1 for vv. */
 | 
|---|
 | 47 | double mjd;
 | 
|---|
 | 48 | double x, y;            /* sw==1: x==ra, y==dec.  sw==-1: x==lng, y==lat. */
 | 
|---|
 | 49 | double *p, *q;          /* sw==1: p==lng, q==lat. sw==-1: p==ra, q==dec. */
 | 
|---|
 | 50 | {
 | 
|---|
 | 51 |         static double lastmjd = -10000; /* last mjd calculated */
 | 
|---|
 | 52 |         static double seps, ceps;       /* sin and cos of mean obliquity */
 | 
|---|
| [1719] | 53 |         double sx, cx, sy, cy, ty, sq;
 | 
|---|
| [1457] | 54 | 
 | 
|---|
 | 55 |         if (mjd != lastmjd) {
 | 
|---|
 | 56 |             double eps;
 | 
|---|
 | 57 |             obliquity (mjd, &eps);              /* mean obliquity for date */
 | 
|---|
 | 58 |             seps = sin(eps);
 | 
|---|
 | 59 |             ceps = cos(eps);
 | 
|---|
 | 60 |             lastmjd = mjd;
 | 
|---|
 | 61 |         }
 | 
|---|
 | 62 | 
 | 
|---|
 | 63 |         sy = sin(y);
 | 
|---|
 | 64 |         cy = cos(y);                            /* always non-negative */
 | 
|---|
 | 65 |         if (fabs(cy)<1e-20) cy = 1e-20;         /* insure > 0 */
 | 
|---|
 | 66 |         ty = sy/cy;
 | 
|---|
 | 67 |         cx = cos(x);
 | 
|---|
 | 68 |         sx = sin(x);
 | 
|---|
| [1719] | 69 |         sq = (sy*ceps)-(cy*seps*sx*sw);
 | 
|---|
 | 70 |         if (sq < -1) sq = -1;
 | 
|---|
 | 71 |         if (sq >  1) sq =  1;
 | 
|---|
 | 72 |         *q = asin(sq);
 | 
|---|
| [1457] | 73 |         *p = atan(((sx*ceps)+(ty*seps*sw))/cx);
 | 
|---|
 | 74 |         if (cx<0) *p += PI;             /* account for atan quad ambiguity */
 | 
|---|
 | 75 |         range (p, 2*PI);
 | 
|---|
 | 76 | }
 | 
|---|
 | 77 | 
 | 
|---|
 | 78 | /* For RCS Only -- Do Not Edit */
 | 
|---|
| [1719] | 79 | static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: eq_ecl.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
 | 
|---|