예제 #1
1
파일: gmst.c 프로젝트: snfraser/astrolib
double slaGmst ( double ut1 )
/*
**  - - - - - - - -
**   s l a G m s t
**  - - - - - - - -
**
**  Conversion from Universal Time to Sidereal Time.
**
**  (double precision)
**
**  Given:
**    ut1    double     Universal Time (strictly UT1) expressed as
**                      Modified Julian Date (JD-2400000.5)
**
**  The result is the Greenwich Mean Sidereal Time (double
**  precision, radians).
**
**  The IAU 1982 expression (see page S15 of the 1984 Astronomical
**  Almanac) is used, but rearranged to reduce rounding errors.
**  This expression is always described as giving the GMST at
**  0 hours UT.  In fact, it gives the difference between the
**  GMST and the UT, which happens to equal the GMST (modulo
**  24 hours) at 0 hours UT each day.  In this routine, the
**  entire UT is used directly as the argument for the
**  standard formula, and the fractional part of the UT is
**  added separately;  note that the factor 1.0027379... does
**  not appear.
**
**  See also the routine slaGmsta, which delivers better numerical
**  precision by accepting the UT date and time as separate arguments.
**
**  Called:  slaDranrm
**
**  Defined in slamac.h:  D2PI, DS2R, dmod
**
**  Last revision:   19 March 1996
**
**  Copyright P.T.Wallace.  All rights reserved.
*/
{
   double tu;

/* Julian centuries from fundamental epoch J2000 to this UT */
   tu = ( ut1 - 51544.5 ) / 36525.0;

/* GMST at this UT */
   return slaDranrm ( dmod ( ut1, 1.0 ) * D2PI +
                       ( 24110.54841 +
                       ( 8640184.812866 +
                       ( 0.093104 - 6.2e-6 * tu ) * tu ) * tu ) * DS2R );
}
double AstAlg_lunar_ascending_node(double jd) {

    static double last_jd, last_ascn;
    double tau, omega;

/* if we've already calculated the value just return it */

    if (jd == last_jd) return last_ascn;

/* calculate the delta-time in centuries with respect to 
   the reference time J2000 */

    tau = (jd - J2000)/36525.0;

/* omega = 125 - 1934 * tau + .002*tau^2 + t^3/4.5e5 */

    omega = (((tau/4.50e5 + 2.0708e-3)*tau - 1.934136261e3)*tau) + 125.04452;

/* now make sure omega is between 0 and 360 */

    omega = dmod(omega, 360.0);

    if (omega < 0.0) omega = omega + 360.0;

    last_jd = jd;
    last_ascn = omega;

    return omega;
}
예제 #3
0
파일: earth.c 프로젝트: Starlink/starlink
void sbmearth(int qfoo,int qbar,float qbaz,float Q0[6])
#define qfobar 1.9913e-7f
#define q1 3.12e-5f
#define q2 8.31e-11f
{float qfoobar,Q3,q4,qfOBAz,qfoobaz,QQUUX,Q5,QFRED,qdog,qcat
,QFISH,QgASp,Q6,q7,q8,QBAD,qBuG,qsilly,QBUGGY,QMUM;int qDAd;
qfoobar=(float)(qfoo-1900);qDAd=qfoo>=0?qfoo%4:3-(-qfoo-1)%4
;Q3=((float)(4*(qbar-1/(qDAd+1))-qDAd-2)+4.0f*qbaz)/1461.0f;
q4=qfoobar+Q3;qfOBAz=(float)dmod(4.881628+D2PI*((double)Q3)+
0.00013420*((double)q4),D2PI);qfoobaz=4.908230f+3.0005e-4f*
q4;QQUUX=qfOBAz-qfoobaz;QFRED=0.40931975f-2.27e-6f*q4;qdog=
0.016751f-4.2e-7f*q4;qcat=(float)(qdog*qdog);QFISH=QQUUX+
2.0f*qdog*(float)sin((double)QQUUX)+1.25f*qcat*(float)sin(
2.0*(double)QQUUX);Q5=QFISH+qfoobaz;QgASp=(1.0f-qcat)/(1.0f+
qdog*(float)cos((double)QFISH));Q6=(float)dmod((4.72+83.9971
*((double)q4)),D2PI);q7=(float)cos((double)Q5);q8=(float)sin
((double)QFRED);QBAD=(float)cos((double)QFRED);qBuG=-QgASp*(
float)sin((double)Q5);qsilly=-qfobar*(q7+qdog*(float)cos((
double)qfoobaz));QBUGGY=(float)sin((double)Q6);QMUM=(float)
cos((double)Q6);Q0[0]=-QgASp*q7-q1*QMUM;Q0[1]=(qBuG-q1*
QBUGGY)*QBAD;Q0[2]=qBuG*q8;Q0[3]=qfobar*((float)sin((double)
Q5)+qdog*(float)sin((double)qfoobaz))+q2*QBUGGY;Q0[4]=(
qsilly-q2*QMUM)*QBAD;Q0[5]=qsilly*q8;}
예제 #4
0
파일: moon.c 프로젝트: Starlink/starlink
void sbmmoon(int qfoo,int qbar,float qbaz,float Q0[6])
#define qfobar 0.01745329252f
#define q1 9.652743551e-12f
#define q2 4.2635212653763e-5f
{int qfoobar,Q3;float q4,qfOBAz,qfoobaz,QQUUX,Q5,QFRED,qdog,
qcat,QFISH,QgASp,Q6,q7,q8,QBAD,qBuG,qsilly,QBUGGY,QMUM,qDAd,
q9,p,Q10,Q11,q12,Q13,Q14,qdisk,Q15,q16,q17,QEMPTY,q18,QFULL,
qfast,qsmall,QBIG,QOK,QHELLO,QBYE,QMAGIC,q19;static float
q20=270.434164f;static float qobSCUrE=4812.678831f;static
float QSPEED=4680.0f;static float qIndex=132.678831f;static
float Q21=358.475833f;static float qbill=359.990498f;static
float q22=359.990498f;static float q23=296.104608f;static
float qjoe=4771.988491f;static float qemacs=4680.0f;static
float q24=91.988491f;static float QVI=350.737486f;static
float qrms=4452.671142f;static float QfbI=4320.0f;static
float Qcia=132.671142f;static float Q25=11.250889f;static
float Q26=4832.020251f;static float QNASA=4680.0f;static
float QERR=152.020251f;struct Q27{float Q28;int qgoogle;int
q29;int QYahoO;int Q30;};static struct Q27 qtrick[]={{
6.288750f,0,1,0,0},{1.274018f,0,-1,2,0},{0.658309f,0,0,2,0},
{0.213616f,0,2,0,0},{-0.185596f,1,0,0,0},{-0.114336f,0,0,0,2
},{0.058793f,0,-2,2,0},{0.057212f,-1,-1,2,0},{0.053320f,0,1,
2,0},{0.045874f,-1,0,2,0},{0.041024f,-1,1,0,0},{-0.034718f,0
,0,1,0},{-0.030465f,1,1,0,0},{0.015326f,0,0,2,-2},{-
0.012528f,0,1,0,2},{-0.010980f,0,-1,0,2},{0.010674f,0,-1,4,0
},{0.010034f,0,3,0,0},{0.008548f,0,-2,4,0},{-0.007910f,1,-1,
2,0},{-0.006783f,1,0,2,0},{0.005162f,0,1,-1,0},{0.005000f,1,
0,1,0},{0.004049f,-1,1,2,0},{0.003996f,0,2,2,0},{0.003862f,0
,0,4,0},{0.003665f,0,-3,2,0},{0.002695f,-1,2,0,0},{0.002602f
,0,1,-2,-2},{0.002396f,-1,-2,2,0},{-0.002349f,0,1,1,0},{
0.002249f,-2,0,2,0},{-0.002125f,1,2,0,0},{-0.002079f,2,0,0,0
},{0.002059f,-2,-1,2,0},{-0.001773f,0,1,2,-2},{-0.001595f,0,
0,2,2},{0.001220f,-1,-1,4,0},{-0.001110f,0,2,0,2}};static
int q31=(sizeof qtrick/sizeof(struct Q27));static struct Q27
 Q32[]={{5.128189f,0,0,0,1},{0.280606f,0,1,0,1},{0.277693f,0
,1,0,-1},{0.173238f,0,0,2,-1},{0.055413f,0,-1,2,1},{
0.046272f,0,-1,2,-1},{0.032573f,0,0,2,1},{0.017198f,0,2,0,1}
,{0.009267f,0,1,2,-1},{0.008823f,0,2,0,-1},{0.008247f,-1,0,2
,-1},{0.004323f,0,-2,2,-1},{0.004200f,0,1,2,1},{0.003372f,-1
,0,-2,1},{0.002472f,-1,-1,2,1},{0.002222f,-1,0,2,1},{
0.002072f,-1,-1,2,-1},{0.001877f,-1,1,0,1},{0.001828f,0,-1,4
,-1},{-0.001803f,1,0,0,1},{-0.001750f,0,0,0,3},{0.001570f,-1
,1,0,-1},{-0.001487f,0,0,1,1},{-0.001481f,1,1,0,1},{
0.001417f,-1,-1,0,1},{0.001350f,-1,0,0,1},{0.001330f,0,0,-1,
1},{0.001106f,0,3,0,1},{0.001020f,0,0,4,-1}};static int
QHINT=(sizeof Q32/sizeof(struct Q27));static struct Q27 Q33[
]={{0.950724f,0,0,0,0},{0.051818f,0,1,0,0},{0.009531f,0,-1,2
,0},{0.007843f,0,0,2,0},{0.002824f,0,2,0,0}};static int Q34=
(sizeof Q33/sizeof(struct Q27));q4=(float)(qfoo-1900);
qfoobar=qfoo>=4?qfoo%4:3-(-qfoo-1)%4;qfOBAz=((float)(4*(qbar
-1/(qfoobar+1))-qfoobar-2)+(4.0f*qbaz))/1461.0f;qfoobaz=q4+
qfOBAz;QQUUX=qfobar*(float)dmod((double)(q20+QSPEED*qfOBAz+
qIndex*qfoobaz),360.0);Q5=qfobar*(float)dmod((double)(Q21+
q22*qfoobaz),360.0);QFRED=qfobar*(float)dmod((double)(q23+
qemacs*qfOBAz+q24*qfoobaz),360.0);qdog=qfobar*(float)dmod((
double)(QVI+QfbI*qfOBAz+Qcia*qfoobaz),360.0);qcat=qfobar*(
float)dmod((double)(Q25+QNASA*qfOBAz+QERR*qfoobaz),360.0);
QFISH=0.0f;QgASp=0.0f;for(Q3=q31-1;Q3>=0;Q3--){qBuG=qtrick[
Q3].Q28;Q6=(float)qtrick[Q3].qgoogle;q7=(float)qtrick[Q3].
q29;q8=(float)qtrick[Q3].QYahoO;QBAD=(float)qtrick[Q3].Q30;
qsilly=Q6*Q5+q7*QFRED+q8*qdog+QBAD*qcat;QFISH+=qBuG*((float)
sin((double)qsilly));QgASp+=qBuG*((float)cos((double)qsilly)
)*(Q6*qbill+q7*qjoe+q8*qrms+QBAD*Q26);}QBUGGY=QQUUX+qfobar*
QFISH;QMUM=q1*(qobSCUrE/qfobar+QgASp);QFISH=0.0f;QgASp=0.0f;
for(Q3=QHINT-1;Q3>=0;Q3--){qBuG=Q32[Q3].Q28;Q6=(float)Q32[Q3
].qgoogle;q7=(float)Q32[Q3].q29;q8=(float)Q32[Q3].QYahoO;
QBAD=(float)Q32[Q3].Q30;qsilly=Q6*Q5+q7*QFRED+q8*qdog+QBAD*
qcat;QFISH+=qBuG*((float)sin((double)qsilly));QgASp+=qBuG*((
float)cos((double)qsilly))*(Q6*qbill+q7*qjoe+q8*qrms+QBAD*
Q26);}qDAd=qfobar*QFISH;q9=q1*QgASp;QFISH=0.0f;QgASp=0.0f;
for(Q3=Q34-1;Q3>=0;Q3--){qBuG=Q33[Q3].Q28;Q6=(float)Q33[Q3].
qgoogle;q7=(float)Q33[Q3].q29;q8=(float)Q33[Q3].QYahoO;QBAD=
(float)Q33[Q3].Q30;qsilly=Q6*Q5+q7*QFRED+q8*qdog+QBAD*qcat;
QFISH+=qBuG*((float)cos((double)qsilly));QgASp+=qBuG*(-(
float)sin((double)qsilly))*(Q6*qbill+q7*qjoe+q8*qrms+QBAD*
Q26);}p=qfobar*QFISH;Q10=q1*QgASp;Q11=(float)sin((double)p);
q12=q2/Q11;Q13=-q12*Q10*(float)(cos((double)p))/Q11;q18=(
float)sin((double)QBUGGY);QFULL=(float)cos((double)QBUGGY);
qfast=(float)sin((double)qDAd);qsmall=(float)cos((double)
qDAd);QBIG=q12*qsmall;QOK=q12*q9;QHELLO=QOK*qfast-qsmall*Q13
;Q14=QBIG*QFULL;qdisk=QBIG*q18;Q15=q12*qfast;q16=-qdisk*QMUM
-QHELLO*QFULL;q17=Q14*QMUM-QHELLO*q18;QEMPTY=QOK*qsmall+
qfast*Q13;QBYE=qfobar*(23.45229f-0.00013f*qfoobaz);QMAGIC=(
float)sin((double)QBYE);q19=(float)cos((double)QBYE);Q0[0]=
Q14;Q0[1]=qdisk*q19-Q15*QMAGIC;Q0[2]=qdisk*QMAGIC+Q15*q19;Q0
[3]=q16;Q0[4]=q17*q19-QEMPTY*QMAGIC;Q0[5]=q17*QMAGIC+QEMPTY*
q19;}
예제 #5
0
void slaPlanet ( double date, int np, double pv[6], int *jstat )
/*
**  - - - - - - - - - -
**   s l a P l a n e t
**  - - - - - - - - - -
**
**  Approximate heliocentric position and velocity of a specified
**  major planet (Mercury, Venus, EMB, Mars, Jupiter, Saturn, Uranus
**  or Neptune).
**
**  Given:
**     date     double      TDB (loosely ET) as a Modified Julian Date
**                                                  (JD-2400000.5)
**     np       int         planet (1=Mercury, 2=Venus, 3=EMB, ...
**                                                  ... 8=Neptune)
**
**  Returned:
**     pv       double[6]   heliocentric x,y,z,xdot,ydot,zdot, J2000
**                                           equatorial triad (AU,AU/s)
**
**     *jstat   int         status: -1 = illegal NP (outside 1-8)
**                                   0 = OK
**                                  +1 = warning: date outside 1000-3000
**                                  +2 = warning: solution didn't converge
**
**  Notes
**
**  1  The epoch, date, is in the TDB timescale and is a Modified
**     Julian Date (JD-2400000.5).
**
**  2  The reference frame is equatorial and is with respect to the
**     mean equinox and ecliptic of epoch J2000.
**
**  3  If an np value outside the range 1-8 is supplied, an error
**     status (jstat = -1) is returned and the pv vector set to zeroes.
**
**  4  The algorithm is due to J.L. Simon, P. Bretagnon, J. Chapront,
**     M. Chapront-Touze, G. Francou and J. Laskar (Bureau des
**     Longitudes, Paris, France).
**
**  5  Comparisons of the present routine with the JPL DE200 ephemeris
**     give the following RMS errors over the interval 1960-2025:
**
**                      position (km)     speed (metre/sec)
**
**        Mercury            334               0.437
**        Venus             1060               0.855
**        EMB               2010               0.815
**        Mars              7690               1.98
**        Jupiter          71700               7.70
**        Saturn          199000              19.4
**        Uranus          564000              16.4
**        Neptune         158000              14.4
**
**     From comparisons with DE102, Simon et al quote the following
**     longitude accuracies over the interval 1800-2200:
**
**        Mercury                 4"
**        Venus                   5"
**        EMB                     6"
**        Mars                   17"
**        Jupiter                71"
**        Saturn                 81"
**        Uranus                 86"
**        Neptune                11"
**
**     Over the interval 1000-3000, the accuracy is better than 1.5
**     times that over 1800-2200.  Outside the interval 1000-3000 the
**     accuracy declines.
**
**  6  The present SLALIB C implementation follows the original
**     Simon et al Fortran code closely, and delivers essentially
**     the same results.  The changes are these:
**
**       *  The date is supplied as a Modified Julian Date rather
**          than a Julian Date (MJD = JD - 2400000.5).
**
**       *  The result is returned only in equatorial Cartesian form;
**          the ecliptic longitude, latitude and radius vector are not
**          returned.
**
**       *  The result is in the J2000 equatorial frame, not ecliptic.
**
**       *  The velocity is in AU per second, not AU per day.
**
**       *  Everything is done in-line:  there are no calls to other
**          routines.
**
**       *  Different error/warning status values are used.
**
**       *  A different Kepler's-equation-solver is used (avoiding
**          use of COMPLEX*16).
**
**       *  Polynomials in T are nested to minimize rounding errors.
**
**       *  Explicit double-precision constants are used to avoid
**          mixed-mode expressions.
**
**  7  For np=3 the result is for the Earth-Moon Barycentre.  To
**     obtain the heliocentric position and velocity of the Earth,
**     either use the SLALIB routine slaEvp or use slaDmoon and
**     subtract 0.012150581 times the geocentric Moon vector from
**     the EMB vector produced by the present routine.  (The Moon
**     vector should be precessed to J2000 first, but this can
**     be omitted for modern epochs without introducing significant
**     inaccuracy.)
**
**  8  The status, jstat, indicates the most serious condition
**     encountered, where illegal np is considered the most serious,
**     followed by failure to converge, then remote epoch.
**
**  Reference:  Astron. Astrophys. 282, 663 (1994).
**
**  Defined in slamac.h:  D2PI, DAS2R, dmod
**
**  Last revision:   19 March 1996
**
**  Copyright P.T.Wallace.  All rights reserved.
*/

#define KMAX    10                    /* Maximum number of iterations  */
                                      /* allowed when solving Kepler's */
                                      /* equation                      */

#define SINEPS  0.3977771559319137    /* Sin and cos of J2000 mean */
#define COSEPS  0.9174820620691818    /* obliquity (IAU 1976)      */

#define GKS     1.99098367477e-7      /* Gaussian gravitational constant */
                                      /* divided by seconds per day      */
                                      /* ( 0.017202098950 / 86400 )      */
{
   int i, ip, j, k;
   double t, da, dl, de, dp, di, dom, dmu, arga, argl, am, ae,
          dae, ae2, at, r, v, si2, xq, xp, tl, xsw, xcw, xm2,
          xf, ci2, xms, xmc, xpxq2, x, y, z;

/* Planetary inverse masses */
   static double amas[8] = {
      6023600.0,
       408523.5,
       328900.5,
      3098710.0,
       1047.355,
         3498.5,
        22869.0,
        19314.0
   };

/*
**    Tables giving the mean Keplerian elements, limited to T^2 terms:
**
**    a       semi-major axis (AU)
**    dlm     mean longitude (degree and arcsecond)
**    e       eccentricity
**    pi      longitude of the perihelion (degree and arcsecond)
**    dinc    inclination (degree and arcsecond)
**    omega   longitude of the ascending node (degree and arcsecond)
*/
   static double a[8][3] = {
      {  0.3870983098,           0.0,     0.0 },
      {  0.7233298200,           0.0,     0.0 },
      {  1.0000010178,           0.0,     0.0 },
      {  1.5236793419,         3e-10,     0.0 },
      {  5.2026032092,     19132e-10, -39e-10 },
      {  9.5549091915, -0.0000213896, 444e-10 },
      { 19.2184460618,     -3716e-10, 979e-10 },
      { 30.1103868694,    -16635e-10, 686e-10 }
   };
   static double dlm[8][3] = {
      { 252.25090552, 5381016286.88982,  -1.92789 },
      { 181.97980085, 2106641364.33548,   0.59381 },
      { 100.46645683, 1295977422.83429,  -2.04411 },
      { 355.43299958,  689050774.93988,   0.94264 },
      {  34.35151874,  109256603.77991, -30.60378 },
      {  50.07744430,   43996098.55732,  75.61614 },
      { 314.05500511,   15424811.93933,  -1.75083 },
      { 304.34866548,    7865503.20744,   0.21103 }
   };
   static double e[8][3] = {
      { 0.2056317526,  0.0002040653,      -28349e-10 },
      { 0.0067719164, -0.0004776521,       98127e-10 },
      { 0.0167086342, -0.0004203654,   -0.0000126734 },
      { 0.0934006477,  0.0009048438,      -80641e-10 },
      { 0.0484979255,  0.0016322542,   -0.0000471366 },
      { 0.0555481426, -0.0034664062,   -0.0000643639 },
      { 0.0463812221, -0.0002729293,    0.0000078913 },
      { 0.0094557470,  0.0000603263,             0.0 }
   };
   static double pi[8][3] = {
      {  77.45611904,  5719.11590,   -4.83016 },
      { 131.56370300,   175.48640, -498.48184 },
      { 102.93734808, 11612.35290,   53.27577 },
      { 336.06023395, 15980.45908,  -62.32800 },
      {  14.33120687,  7758.75163,  259.95938 },
      {  93.05723748, 20395.49439,  190.25952 },
      { 173.00529106,  3215.56238,  -34.09288 },
      {  48.12027554,  1050.71912,   27.39717 }
   };
   static double dinc[8][3] = {
      { 7.00498625, -214.25629,   0.28977 },
      { 3.39466189,  -30.84437, -11.67836 },
      {        0.0,  469.97289,  -3.35053 },
      { 1.84972648, -293.31722,  -8.11830 },
      { 1.30326698,  -71.55890,  11.95297 },
      { 2.48887878,   91.85195, -17.66225 },
      { 0.77319689,  -60.72723,   1.25759 },
      { 1.76995259,    8.12333,   0.08135 }
   };
   static double omega[8][3] = {
      {  48.33089304,  -4515.21727,  -31.79892 },
      {  76.67992019, -10008.48154,  -51.32614 },
      { 174.87317577,  -8679.27034,   15.34191 },
      {  49.55809321, -10620.90088, -230.57416 },
      { 100.46440702,   6362.03561,  326.52178 },
      { 113.66550252,  -9240.19942,  -66.23743 },
      {  74.00595701,   2669.15033,  145.93964 },
      { 131.78405702,   -221.94322,   -0.78728 }
   };
/*
**    Tables for trigonometric terms to be added to the mean elements
**    of the semi-major axes.
*/
   static double kp[8][9] = {
      { 69613.0, 75645.0, 88306.0, 59899.0, 15746.0, 71087.0,
                                                142173.0,  3086.0,    0.0 },
      { 21863.0, 32794.0, 26934.0, 10931.0, 26250.0, 43725.0,
                                                 53867.0, 28939.0,    0.0 },
      { 16002.0, 21863.0, 32004.0, 10931.0, 14529.0, 16368.0,
                                                 15318.0, 32794.0,    0.0 },
      {  6345.0,  7818.0, 15636.0,  7077.0,  8184.0, 14163.0,
                                                  1107.0,  4872.0,    0.0 },
      {  1760.0,  1454.0,  1167.0,   880.0,   287.0,  2640.0,
                                                    19.0,  2047.0, 1454.0 },
      {   574.0,     0.0,   880.0,   287.0,    19.0,  1760.0,
                                                  1167.0,   306.0,  574.0 },
      {   204.0,     0.0,   177.0,  1265.0,     4.0,   385.0,
                                                   200.0,   208.0,  204.0 },
      {     0.0,   102.0,   106.0,     4.0,    98.0,  1367.0,
                                                   487.0,   204.0,    0.0 }
   };
   static double ca[8][9] = {
    {       4.0,    -13.0,    11.0,    -9.0,    -9.0,    -3.0,
                                                    -1.0,     4.0,    0.0 },
    {    -156.0,     59.0,   -42.0,     6.0,    19.0,   -20.0,
                                                   -10.0,   -12.0,    0.0 },
    {      64.0,   -152.0,    62.0,    -8.0,    32.0,   -41.0,
                                                    19.0,   -11.0,    0.0 },
    {     124.0,    621.0,  -145.0,   208.0,    54.0,   -57.0,
                                                    30.0,    15.0,    0.0 },
    {  -23437.0,  -2634.0,  6601.0,  6259.0, -1507.0, -1821.0,
                                                  2620.0, -2115.0,-1489.0 },
    {   62911.0,-119919.0, 79336.0, 17814.0,-24241.0, 12068.0,
                                                  8306.0, -4893.0, 8902.0 },
    {  389061.0,-262125.0,-44088.0,  8387.0,-22976.0, -2093.0,
                                                  -615.0, -9720.0, 6633.0 },
    { -412235.0,-157046.0,-31430.0, 37817.0, -9740.0,   -13.0,
                                                 -7449.0,  9644.0,    0.0 }
   };
   static double sa[8][9] = {
      {     -29.0,    -1.0,     9.0,     6.0,    -6.0,     5.0,
                                                     4.0,     0.0,    0.0 },
      {     -48.0,  -125.0,   -26.0,   -37.0,    18.0,   -13.0,
                                                   -20.0,    -2.0,    0.0 },
      {    -150.0,   -46.0,    68.0,    54.0,    14.0,    24.0,
                                                   -28.0,    22.0,    0.0 },
      {    -621.0,   532.0,  -694.0,   -20.0,   192.0,   -94.0,
                                                    71.0,   -73.0,    0.0 },
      {  -14614.0,-19828.0, -5869.0,  1881.0, -4372.0, -2255.0,
                                                   782.0,   930.0,  913.0 },
      {  139737.0,     0.0, 24667.0, 51123.0, -5102.0,  7429.0,
                                                 -4095.0, -1976.0,-9566.0 },
      { -138081.0,     0.0, 37205.0,-49039.0,-41901.0,-33872.0,
                                                -27037.0,-12474.0,18797.0 },
      {       0.0, 28492.0,133236.0, 69654.0, 52322.0,-49577.0,
                                                -26430.0, -3593.0,    0.0 }
   };
/*
**    Tables giving the trigonometric terms to be added to the mean
**    elements of the mean longitudes.
*/
   static double kq[8][10] = {
      {  3086.0, 15746.0, 69613.0, 59899.0, 75645.0,
                                      88306.0, 12661.0, 2658.0,  0.0,   0.0 },
      { 21863.0, 32794.0, 10931.0,    73.0,  4387.0,
                                      26934.0,  1473.0, 2157.0,  0.0,   0.0 },
      {    10.0, 16002.0, 21863.0, 10931.0,  1473.0,
                                      32004.0,  4387.0,   73.0,  0.0,   0.0 },
      {    10.0,  6345.0,  7818.0,  1107.0, 15636.0,
                                       7077.0,  8184.0,  532.0, 10.0,   0.0 },
      {    19.0,  1760.0,  1454.0,   287.0,  1167.0,
                                        880.0,   574.0, 2640.0, 19.0,1454.0 },
      {    19.0,   574.0,   287.0,   306.0,  1760.0,
                                         12.0,    31.0,   38.0, 19.0, 574.0 },
      {     4.0,   204.0,   177.0,     8.0,    31.0,
                                        200.0,  1265.0,  102.0,  4.0, 204.0 },
      {     4.0,   102.0,   106.0,     8.0,    98.0,
                                       1367.0,   487.0,  204.0,  4.0, 102.0 }
   };
   static double cl[8][10] = {
    {      21.0,    -95.0,  -157.0,    41.0,    -5.0,
                                      42.0,   23.0,   30.0,     0.0,    0.0 },
    {    -160.0,   -313.0,  -235.0,    60.0,   -74.0,
                                     -76.0,  -27.0,   34.0,     0.0,    0.0 },
    {    -325.0,   -322.0,   -79.0,   232.0,   -52.0,
                                      97.0,   55.0,  -41.0,     0.0,    0.0 },
    {    2268.0,   -979.0,   802.0,   602.0,  -668.0,
                                     -33.0,  345.0,  201.0,   -55.0,    0.0 },
    {    7610.0,  -4997.0, -7689.0, -5841.0, -2617.0,
                                    1115.0, -748.0, -607.0,  6074.0,  354.0 },
    {  -18549.0,  30125.0, 20012.0,  -730.0,   824.0,
                                      23.0, 1289.0, -352.0,-14767.0,-2062.0 },
    { -135245.0, -14594.0,  4197.0, -4030.0, -5630.0,
                                   -2898.0, 2540.0, -306.0,  2939.0, 1986.0 },
    {   89948.0,   2103.0,  8963.0,  2695.0,  3682.0,
                                    1648.0,  866.0, -154.0, -1963.0, -283.0 }
   };
   static double sl[8][10] = {
    {   -342.0,    136.0,   -23.0,    62.0,    66.0,
                                 -52.0,   -33.0,    17.0,     0.0,     0.0 },
    {    524.0,   -149.0,   -35.0,   117.0,   151.0,
                                 122.0,   -71.0,   -62.0,     0.0,     0.0 },
    {   -105.0,   -137.0,   258.0,    35.0,  -116.0,
                                 -88.0,  -112.0,   -80.0,     0.0,     0.0 },
    {    854.0,   -205.0,  -936.0,  -240.0,   140.0,
                                -341.0,   -97.0,  -232.0,   536.0,     0.0 },
    { -56980.0,   8016.0,  1012.0,  1448.0, -3024.0,
                               -3710.0,   318.0,   503.0,  3767.0,   577.0 },
    { 138606.0, -13478.0, -4964.0,  1441.0, -1319.0,
                               -1482.0,   427.0,  1236.0, -9167.0, -1918.0 },
    {  71234.0, -41116.0,  5334.0, -4935.0, -1848.0,
                                  66.0,   434.0, -1748.0,  3780.0,  -701.0 },
    { -47645.0,  11647.0,  2166.0,  3194.0,   679.0,
                                   0.0,  -244.0,  -419.0, -2531.0,    48.0 }
   };


/* Validate the planet number */
   if ( np < 1 || np > 8 ) {
      *jstat = -1;
      for ( i = 0; i <= 5; i++ ) pv[i] = 0.0;
      return;
   } else {
      ip = np - 1;
   }

/* Time: Julian millennia since J2000 */
   t = ( date - 51544.5 ) / 365250.0;

/* OK status unless remote epoch */
   *jstat = ( fabs ( t ) <= 1.0 ) ? 0 : 1;

/* Compute the mean elements */
   da = a[ip][0] + ( a[ip][1] + a[ip][2] * t ) * t;
   dl = ( 3600.0 * dlm[ip][0] + ( dlm[ip][1] + dlm[ip][2] * t ) * t )
                                                                  * DAS2R;
   de = e[ip][0] + ( e[ip][1] + e[ip][2] * t ) * t;
   dp = dmod ( ( 3600.0 * pi[ip][0] + ( pi[ip][1] + pi[ip][2] * t ) * t )
                                                           * DAS2R,D2PI );
   di = ( 3600.0 * dinc[ip][0] + ( dinc[ip][1] + dinc[ip][2] * t ) * t )
                                                                  * DAS2R;
   dom = dmod( ( 3600.0 * omega[ip][0] + ( omega[ip][1]
                               + omega[ip][2] * t ) * t ) * DAS2R, D2PI );

/* Apply the trigonometric terms */
   dmu = 0.35953620 * t;
   for ( j = 0; j <= 7; j++ ) {
      arga = kp[ip][j] * dmu;
      argl = kq[ip][j] * dmu;
      da += ( ca[ip][j] * cos ( arga ) + sa[ip][j] * sin ( arga ) ) * 1e-7;
      dl += ( cl[ip][j] * cos ( argl ) + sl[ip][j] * sin ( argl ) ) * 1e-7;
   }
   arga = kp[ip][8] * dmu;
   da += t * ( ca[ip][8] * cos ( arga ) + sa[ip][8] * sin ( arga ) ) * 1e-7;
   for ( j = 8; j <= 9; j++ ) {
      argl = kq[ip][j] * dmu;
      dl += t * ( cl[ip][j] * cos ( argl ) + sl[ip][j] * sin ( argl ) )
                                                                     * 1e-7;
   }
   dl = dmod ( dl, D2PI );

/* Iterative solution of Kepler's equation to get eccentric anomaly */
   am = dl - dp;
   ae = am + de * sin ( am );
   k = 0;
   do {
      dae = ( am - ae + de * sin ( ae ) ) / ( 1.0 - de * cos ( ae ) );
      ae += dae;
      if ( k++ >= KMAX ) *jstat = 2;
      }
   while ( k < KMAX && fabs ( dae ) > 1e-12 );

/* True anomaly */
   ae2 = ae / 2.0;
   at = 2.0 * atan2 ( sqrt ( ( 1.0 + de ) / ( 1.0 - de ) )
                                           * sin ( ae2 ), cos ( ae2 ) );

/* Distance (AU) and speed (radians per second) */
   r = da * ( 1.0 - de * cos ( ae ) );
   v = GKS * sqrt ( ( 1.0 + 1.0 / amas[ip] ) / ( da * da * da ) );

   si2 = sin ( di / 2.0 );
   xq = si2 * cos ( dom );
   xp = si2 * sin ( dom );
   tl = at + dp;
   xsw = sin ( tl );
   xcw = cos ( tl );
   xm2 = 2.0 * ( xp * xcw - xq * xsw );
   xf = da / sqrt ( 1.0 - de * de );
   ci2 = cos ( di / 2 );
   xms = ( de * sin ( dp ) + xsw ) * xf;
   xmc = ( de * cos ( dp ) + xcw ) * xf;
   xpxq2 = 2.0 * xp * xq;

/* Position ( J2000 ecliptic x,y,z in AU ) */
   x = r * ( xcw - xm2 * xp );
   y = r * ( xsw + xm2 * xq );
   z = r * ( - xm2 * ci2 );

/*  Rotate to equatorial */
   pv[0] = x;
   pv[1] = y * COSEPS - z * SINEPS;
   pv[2] = y * SINEPS + z * COSEPS;

/*  Velocity ( J2000 ecliptic xdot,ydot,zdot in AU/s) */
   x = v * ( (  - 1.0 + 2.0 * xp * xp ) * xms + xpxq2 * xmc );
   y = v * ( ( 1.0 - 2.0 * xq * xq ) * xmc - xpxq2 * xms );
   z = v * ( 2.0 * ci2 * ( xp * xms + xq * xmc ) );

/*  Rotate to equatorial */
   pv[3] = x;
   pv[4] = y * COSEPS - z * SINEPS;
   pv[5] = y * SINEPS + z * COSEPS;
}
예제 #6
0
파일: ssynth.c 프로젝트: bsummer4/midiutils
double f2inc (double f) { return dmod(f/(double)SAMPLERATE, 1.0); }
예제 #7
0
파일: planet.c 프로젝트: snfraser/astrolib
void slaPlanet ( double date, int np, double pv[6], int *jstat )
/*
**  - - - - - - - - - -
**   s l a P l a n e t
**  - - - - - - - - - -
**
**  Approximate heliocentric position and velocity of a specified
**  major planet.
**
**  Given:
**     date     double      TDB (loosely ET) as a Modified Julian Date
**                                                  (JD-2400000.5)
**     np       int         planet (1=Mercury, 2=Venus, 3=EMB, ...
**                                                    ... 9=Pluto)
**
**  Returned:
**     pv       double[6]   heliocentric x,y,z,xdot,ydot,zdot, J2000
**                                           equatorial triad (AU,AU/s)
**
**     *jstat   int         status: +1 = warning: date outside 1000-3000
**     *jstat   int         status:  0 = OK
**                                  -1 = illegal NP (outside 1-9)
**                                  -2 = solution didn't converge
**
**  Called:  slaPlanel
**
**  Notes
**
**  1  The epoch, date, is in the TDB timescale and is a Modified
**     Julian Date (JD-2400000.5).
**
**  2  The reference frame is equatorial and is with respect to the
**     mean equinox and ecliptic of epoch J2000.
**
**  3  If an np value outside the range 1-9 is supplied, an error
**     status (jstat = -1) is returned and the pv vector set to zeroes.
**
**  4  The algorithm for obtaining the mean elements of the planets
**     from Mercury to Neptune is due to J.L. Simon, P. Bretagnon,
**     J. Chapront, M. Chapront-Touze, G. Francou and J. Laskar
**     (Bureau des Longitudes, Paris).  The (completely different)
**     algorithm for calculating the ecliptic coordinates of Pluto
**     is by Meeus.
**
**  5  Comparisons of the present routine with the JPL DE200 ephemeris
**     give the following RMS errors over the interval 1960-2025:
**
**                      position (km)     speed (metre/sec)
**
**        Mercury            334               0.437
**        Venus             1060               0.855
**        EMB               2010               0.815
**        Mars              7690               1.98
**        Jupiter          71700               7.70
**        Saturn          199000              19.4
**        Uranus          564000              16.4
**        Neptune         158000              14.4
**
**     From comparisons with DE102, Simon et al quote the following
**     longitude accuracies over the interval 1800-2200:
**
**        Mercury                 4"
**        Venus                   5"
**        EMB                     6"
**        Mars                   17"
**        Jupiter                71"
**        Saturn                 81"
**        Uranus                 86"
**        Neptune                11"
**
**     In the case of Pluto, Meeus quotes an accuracy of 0.6 arcsec
**     in longitude and 0.2 arcsec in latitude for the period
**     1885-2099.
**
**     For all except Pluto, over the period 1000-3000 the accuracy
**     is better than 1.5 times that over 1800-2200.  Outside the
**     period 1000-3000 the accuracy declines.  For Pluto the
**     accuracy declines rapidly outside the period 1885-2099.
**     Outside these ranges (1885-2099 for Pluto, 1000-3000 for
**     the rest) a "date out of range" warning status (JSTAT=+1)
**     is returned.
**
**  6  The algorithms for (i) Mercury through Neptune and (ii) Pluto
**     are completely independent.  In the Mercury through Neptune
**     case, the present SLALIB C implementation follows the original
**     Simon et al Fortran code closely, and delivers essentially
**     the same results.  The changes are these:
**
**     *  The date is supplied as a Modified Julian Date rather
**        than a Julian Date (MJD = JD - 2400000.5).
**
**     *  The result is returned only in equatorial Cartesian form;
**        the ecliptic longitude, latitude and radius vector are not
**        returned.
**
**     *  The velocity is in AU per second, not AU per day.
**
**     *  Different error/warning status values are used.
**
**     *  Kepler's equation is not solved inline.
**
**     *  Polynomials in T are nested to minimize rounding errors.
**
**     *  Explicit double-precision constants are used to avoid
**        mixed-mode expressions.
**
**  7  For np=3 the result is for the Earth-Moon Barycentre.  To
**     obtain the heliocentric position and velocity of the Earth,
**     either use the SLALIB routine slaEvp or use slaDmoon and
**     subtract 0.012150581 times the geocentric Moon vector from
**     the EMB vector produced by the present routine.  (The Moon
**     vector should be precessed to J2000 first, but this can
**     be omitted for modern epochs without introducing significant
**     inaccuracy.)
**
**  References:  Simon et al., Astron. Astrophys. 282, 663 (1994).
**               Meeus, Astronomical Algorithms, Willmann-Bell (1991).
**
**  Defined in slamac.h:  D2PI, DAS2R, DD2R, dmod
**
**  Last revision:   27 May 1997
**
**  Copyright P.T.Wallace.  All rights reserved.
*/

/* Gaussian gravitational constant (exact) */
#define GCON 0.01720209895

/* Canonical days to seconds */
#define CD2S ( GCON / 86400.0 )

/* Seconds per Julian century */
#define SPC ( 36525.0 * 86400.0 )

/* Sin and cos of J2000 mean obliquity (IAU 1976) */
#define SE 0.3977771559319137
#define CE 0.9174820620691818

{
   int ip, i, j;
   double t, da, de, dpe, di, dom, dmu, arga, argl, dm,
          dj, ds, dp, wlbr[3], wlbrd[3],
          wj, ws, wp, al, ald, sal, cal,
          ac, bc, dl, dld, db, dbd, dr, drd,
          sl, cl, sb, cb, slcb, clcb, x, y, z, xd, yd, zd;

/*
** -----------------------
** Mercury through Neptune
** -----------------------
*/

/* Planetary inverse masses */
   static double amas[] = {
      6023600.0,
       408523.5,
       328900.5,
      3098710.0,
       1047.355,
         3498.5,
        22869.0,
        19314.0
   };

/*
**    Tables giving the mean Keplerian elements, limited to T^2 terms:
**
**    a       semi-major axis (AU)
**    dlm     mean longitude (degree and arcsecond)
**    e       eccentricity
**    pi      longitude of the perihelion (degree and arcsecond)
**    dinc    inclination (degree and arcsecond)
**    omega   longitude of the ascending node (degree and arcsecond)
*/
   static double a[8][3] = {
      {  0.3870983098,           0.0,     0.0 },
      {  0.7233298200,           0.0,     0.0 },
      {  1.0000010178,           0.0,     0.0 },
      {  1.5236793419,         3e-10,     0.0 },
      {  5.2026032092,     19132e-10, -39e-10 },
      {  9.5549091915, -0.0000213896, 444e-10 },
      { 19.2184460618,     -3716e-10, 979e-10 },
      { 30.1103868694,    -16635e-10, 686e-10 }
   };
   static double dlm[8][3] = {
      { 252.25090552, 5381016286.88982,  -1.92789 },
      { 181.97980085, 2106641364.33548,   0.59381 },
      { 100.46645683, 1295977422.83429,  -2.04411 },
      { 355.43299958,  689050774.93988,   0.94264 },
      {  34.35151874,  109256603.77991, -30.60378 },
      {  50.07744430,   43996098.55732,  75.61614 },
      { 314.05500511,   15424811.93933,  -1.75083 },
      { 304.34866548,    7865503.20744,   0.21103 }
   };
   static double e[8][3] = {
      { 0.2056317526,  0.0002040653,      -28349e-10 },
      { 0.0067719164, -0.0004776521,       98127e-10 },
      { 0.0167086342, -0.0004203654,   -0.0000126734 },
      { 0.0934006477,  0.0009048438,      -80641e-10 },
      { 0.0484979255,  0.0016322542,   -0.0000471366 },
      { 0.0555481426, -0.0034664062,   -0.0000643639 },
      { 0.0463812221, -0.0002729293,    0.0000078913 },
      { 0.0094557470,  0.0000603263,             0.0 }
   };
   static double pi[8][3] = {
      {  77.45611904,  5719.11590,   -4.83016 },
      { 131.56370300,   175.48640, -498.48184 },
      { 102.93734808, 11612.35290,   53.27577 },
      { 336.06023395, 15980.45908,  -62.32800 },
      {  14.33120687,  7758.75163,  259.95938 },
      {  93.05723748, 20395.49439,  190.25952 },
      { 173.00529106,  3215.56238,  -34.09288 },
      {  48.12027554,  1050.71912,   27.39717 }
   };
   static double dinc[8][3] = {
      { 7.00498625, -214.25629,   0.28977 },
      { 3.39466189,  -30.84437, -11.67836 },
      {        0.0,  469.97289,  -3.35053 },
      { 1.84972648, -293.31722,  -8.11830 },
      { 1.30326698,  -71.55890,  11.95297 },
      { 2.48887878,   91.85195, -17.66225 },
      { 0.77319689,  -60.72723,   1.25759 },
      { 1.76995259,    8.12333,   0.08135 }
   };
   static double omega[8][3] = {
      {  48.33089304,  -4515.21727,  -31.79892 },
      {  76.67992019, -10008.48154,  -51.32614 },
      { 174.87317577,  -8679.27034,   15.34191 },
      {  49.55809321, -10620.90088, -230.57416 },
      { 100.46440702,   6362.03561,  326.52178 },
      { 113.66550252,  -9240.19942,  -66.23743 },
      {  74.00595701,   2669.15033,  145.93964 },
      { 131.78405702,   -221.94322,   -0.78728 }
   };

/*
**    Tables for trigonometric terms to be added to the mean elements
**    of the semi-major axes.
*/
   static double dkp[8][9] = {
      { 69613.0, 75645.0, 88306.0, 59899.0, 15746.0, 71087.0,
                                                142173.0,  3086.0,    0.0 },
      { 21863.0, 32794.0, 26934.0, 10931.0, 26250.0, 43725.0,
                                                 53867.0, 28939.0,    0.0 },
      { 16002.0, 21863.0, 32004.0, 10931.0, 14529.0, 16368.0,
                                                 15318.0, 32794.0,    0.0 },
      {  6345.0,  7818.0, 15636.0,  7077.0,  8184.0, 14163.0,
                                                  1107.0,  4872.0,    0.0 },
      {  1760.0,  1454.0,  1167.0,   880.0,   287.0,  2640.0,
                                                    19.0,  2047.0, 1454.0 },
      {   574.0,     0.0,   880.0,   287.0,    19.0,  1760.0,
                                                  1167.0,   306.0,  574.0 },
      {   204.0,     0.0,   177.0,  1265.0,     4.0,   385.0,
                                                   200.0,   208.0,  204.0 },
      {     0.0,   102.0,   106.0,     4.0,    98.0,  1367.0,
                                                   487.0,   204.0,    0.0 }
   };
   static double ca[8][9] = {
    {       4.0,    -13.0,    11.0,    -9.0,    -9.0,    -3.0,
                                                    -1.0,     4.0,    0.0 },
    {    -156.0,     59.0,   -42.0,     6.0,    19.0,   -20.0,
                                                   -10.0,   -12.0,    0.0 },
    {      64.0,   -152.0,    62.0,    -8.0,    32.0,   -41.0,
                                                    19.0,   -11.0,    0.0 },
    {     124.0,    621.0,  -145.0,   208.0,    54.0,   -57.0,
                                                    30.0,    15.0,    0.0 },
    {  -23437.0,  -2634.0,  6601.0,  6259.0, -1507.0, -1821.0,
                                                  2620.0, -2115.0,-1489.0 },
    {   62911.0,-119919.0, 79336.0, 17814.0,-24241.0, 12068.0,
                                                  8306.0, -4893.0, 8902.0 },
    {  389061.0,-262125.0,-44088.0,  8387.0,-22976.0, -2093.0,
                                                  -615.0, -9720.0, 6633.0 },
    { -412235.0,-157046.0,-31430.0, 37817.0, -9740.0,   -13.0,
                                                 -7449.0,  9644.0,    0.0 }
   };
   static double sa[8][9] = {
      {     -29.0,    -1.0,     9.0,     6.0,    -6.0,     5.0,
                                                     4.0,     0.0,    0.0 },
      {     -48.0,  -125.0,   -26.0,   -37.0,    18.0,   -13.0,
                                                   -20.0,    -2.0,    0.0 },
      {    -150.0,   -46.0,    68.0,    54.0,    14.0,    24.0,
                                                   -28.0,    22.0,    0.0 },
      {    -621.0,   532.0,  -694.0,   -20.0,   192.0,   -94.0,
                                                    71.0,   -73.0,    0.0 },
      {  -14614.0,-19828.0, -5869.0,  1881.0, -4372.0, -2255.0,
                                                   782.0,   930.0,  913.0 },
      {  139737.0,     0.0, 24667.0, 51123.0, -5102.0,  7429.0,
                                                 -4095.0, -1976.0,-9566.0 },
      { -138081.0,     0.0, 37205.0,-49039.0,-41901.0,-33872.0,
                                                -27037.0,-12474.0,18797.0 },
      {       0.0, 28492.0,133236.0, 69654.0, 52322.0,-49577.0,
                                                -26430.0, -3593.0,    0.0 }
   };

/*
**    Tables giving the trigonometric terms to be added to the mean
**    elements of the mean longitudes.
*/
   static double dkq[8][10] = {
      {  3086.0, 15746.0, 69613.0, 59899.0, 75645.0,
                                      88306.0, 12661.0, 2658.0,  0.0,   0.0 },
      { 21863.0, 32794.0, 10931.0,    73.0,  4387.0,
                                      26934.0,  1473.0, 2157.0,  0.0,   0.0 },
      {    10.0, 16002.0, 21863.0, 10931.0,  1473.0,
                                      32004.0,  4387.0,   73.0,  0.0,   0.0 },
      {    10.0,  6345.0,  7818.0,  1107.0, 15636.0,
                                       7077.0,  8184.0,  532.0, 10.0,   0.0 },
      {    19.0,  1760.0,  1454.0,   287.0,  1167.0,
                                        880.0,   574.0, 2640.0, 19.0,1454.0 },
      {    19.0,   574.0,   287.0,   306.0,  1760.0,
                                         12.0,    31.0,   38.0, 19.0, 574.0 },
      {     4.0,   204.0,   177.0,     8.0,    31.0,
                                        200.0,  1265.0,  102.0,  4.0, 204.0 },
      {     4.0,   102.0,   106.0,     8.0,    98.0,
                                       1367.0,   487.0,  204.0,  4.0, 102.0 }
   };
   static double clo[8][10] = {
    {      21.0,    -95.0,  -157.0,    41.0,    -5.0,
                                      42.0,   23.0,   30.0,     0.0,    0.0 },
    {    -160.0,   -313.0,  -235.0,    60.0,   -74.0,
                                     -76.0,  -27.0,   34.0,     0.0,    0.0 },
    {    -325.0,   -322.0,   -79.0,   232.0,   -52.0,
                                      97.0,   55.0,  -41.0,     0.0,    0.0 },
    {    2268.0,   -979.0,   802.0,   602.0,  -668.0,
                                     -33.0,  345.0,  201.0,   -55.0,    0.0 },
    {    7610.0,  -4997.0, -7689.0, -5841.0, -2617.0,
                                    1115.0, -748.0, -607.0,  6074.0,  354.0 },
    {  -18549.0,  30125.0, 20012.0,  -730.0,   824.0,
                                      23.0, 1289.0, -352.0,-14767.0,-2062.0 },
    { -135245.0, -14594.0,  4197.0, -4030.0, -5630.0,
                                   -2898.0, 2540.0, -306.0,  2939.0, 1986.0 },
    {   89948.0,   2103.0,  8963.0,  2695.0,  3682.0,
                                    1648.0,  866.0, -154.0, -1963.0, -283.0 }
   };
   static double slo[8][10] = {
    {   -342.0,    136.0,   -23.0,    62.0,    66.0,
                                 -52.0,   -33.0,    17.0,     0.0,     0.0 },
    {    524.0,   -149.0,   -35.0,   117.0,   151.0,
                                 122.0,   -71.0,   -62.0,     0.0,     0.0 },
    {   -105.0,   -137.0,   258.0,    35.0,  -116.0,
                                 -88.0,  -112.0,   -80.0,     0.0,     0.0 },
    {    854.0,   -205.0,  -936.0,  -240.0,   140.0,
                                -341.0,   -97.0,  -232.0,   536.0,     0.0 },
    { -56980.0,   8016.0,  1012.0,  1448.0, -3024.0,
                               -3710.0,   318.0,   503.0,  3767.0,   577.0 },
    { 138606.0, -13478.0, -4964.0,  1441.0, -1319.0,
                               -1482.0,   427.0,  1236.0, -9167.0, -1918.0 },
    {  71234.0, -41116.0,  5334.0, -4935.0, -1848.0,
                                  66.0,   434.0, -1748.0,  3780.0,  -701.0 },
    { -47645.0,  11647.0,  2166.0,  3194.0,   679.0,
                                   0.0,  -244.0,  -419.0, -2531.0,    48.0 }
   };

/*
** -----
** Pluto
** -----
*/

/*
** Coefficients for fundamental arguments:  mean longitudes (degrees)
** and mean rate of change of longitude (degrees per Julian century)
** for Jupiter, Saturn and Pluto
*/
   static double dj0 = 34.35, djd = 3034.9057,
                 ds0 = 50.08, dsd = 1222.1138,
                 dp0 = 238.96, dpd = 144.9600;

/* Coefficients for latitude, longitude, radius vector */
   static double dl0 = 238.956785, dld0 = 144.96,
                 db0 = -3.908202,
                 dr0 = 40.7247248;

/*
** Coefficients for periodic terms (Meeus's Table 36.A)
*/
   struct ab {
      double a;           /* sine component */
      double b;           /* cosine component */
   };
   struct tm {
      int ij;             /* Jupiter contribution to argument */
      int is;             /* Saturn contribution to argument */
      int ip;             /* Pluto contribution to argument */
      struct ab dlbr[3];  /* longitude (degrees),
                             latitude (degrees),
                             radius vector (AU) */
   };
   static struct tm term[] = {

   /*  1 */   { 0,  0,  1, { { -19798886e-6,  19848454e-6 },
                             {  -5453098e-6, -14974876e-6 },
                             {  66867334e-7,  68955876e-7 } } },
   /*  2 */   { 0,  0,  2, { {    897499e-6,  -4955707e-6 },
                             {   3527363e-6,   1672673e-6 },
                             { -11826086e-7,   -333765e-7 } } },
   /*  3 */   { 0,  0,  3, { {    610820e-6,   1210521e-6 },
                             {  -1050939e-6,    327763e-6 },
                             {   1593657e-7,  -1439953e-7 } } },
   /*  4 */   { 0,  0,  4, { {   -341639e-6,   -189719e-6 },
                             {    178691e-6,   -291925e-6 },
                             {    -18948e-7,    482443e-7 } } },
   /*  5 */   { 0,  0,  5, { {    129027e-6,    -34863e-6 },
                             {     18763e-6,    100448e-6 },
                             {    -66634e-7,    -85576e-7 } } },
   /*  6 */   { 0,  0,  6, { {    -38215e-6,     31061e-6 },
                             {    -30594e-6,    -25838e-6 },
                             {     30841e-7,     -5765e-7 } } },
   /*  7 */   { 0,  1, -1, { {     20349e-6,     -9886e-6 },
                             {      4965e-6,     11263e-6 },
                             {     -6140e-7,     22254e-7 } } },
   /*  8 */   { 0,  1,  0, { {     -4045e-6,     -4904e-6 },
                             {       310e-6,      -132e-6 },
                             {      4434e-7,      4443e-7 } } },
   /*  9 */   { 0,  1,  1, { {     -5885e-6,     -3238e-6 },
                             {      2036e-6,      -947e-6 },
                             {     -1518e-7,       641e-7 } } },
   /* 10 */   { 0,  1,  2, { {     -3812e-6,      3011e-6 },
                             {        -2e-6,      -674e-6 },
                             {        -5e-7,       792e-7 } } },
   /* 11 */   { 0,  1,  3, { {      -601e-6,      3468e-6 },
                             {      -329e-6,      -563e-6 },
                             {       518e-7,       518e-7 } } },
   /* 12 */   { 0,  2, -2, { {      1237e-6,       463e-6 },
                             {       -64e-6,        39e-6 },
                             {       -13e-7,      -221e-7 } } },
   /* 13 */   { 0,  2, -1, { {      1086e-6,      -911e-6 },
                             {       -94e-6,       210e-6 },
                             {       837e-7,      -494e-7 } } },
   /* 14 */   { 0,  2,  0, { {       595e-6,     -1229e-6 },
                             {        -8e-6,      -160e-6 },
                             {      -281e-7,       616e-7 } } },
   /* 15 */   { 1, -1,  0, { {      2484e-6,      -485e-6 },
                             {      -177e-6,       259e-6 },
                             {       260e-7,      -395e-7 } } },
   /* 16 */   { 1, -1,  1, { {       839e-6,     -1414e-6 },
                             {        17e-6,       234e-6 },
                             {      -191e-7,      -396e-7 } } },
   /* 17 */   { 1,  0, -3, { {      -964e-6,      1059e-6 },
                             {       582e-6,      -285e-6 },
                             {     -3218e-7,       370e-7 } } },
   /* 18 */   { 1,  0, -2, { {     -2303e-6,     -1038e-6 },
                             {      -298e-6,       692e-6 },
                             {      8019e-7,     -7869e-7 } } },
   /* 19 */   { 1,  0, -1, { {      7049e-6,       747e-6 },
                             {       157e-6,       201e-6 },
                             {       105e-7,     45637e-7 } } },
   /* 20 */   { 1,  0,  0, { {      1179e-6,      -358e-6 },
                             {       304e-6,       825e-6 },
                             {      8623e-7,      8444e-7 } } },
   /* 21 */   { 1,  0,  1, { {       393e-6,       -63e-6 },
                             {      -124e-6,       -29e-6 },
                             {      -896e-7,      -801e-7 } } },
   /* 22 */   { 1,  0,  2, { {       111e-6,      -268e-6 },
                             {        15e-6,         8e-6 },
                             {       208e-7,      -122e-7 } } },
   /* 23 */   { 1,  0,  3, { {       -52e-6,      -154e-6 },
                             {         7e-6,        15e-6 },
                             {      -133e-7,        65e-7 } } },
   /* 24 */   { 1,  0,  4, { {       -78e-6,       -30e-6 },
                             {         2e-6,         2e-6 },
                             {       -16e-7,         1e-7 } } },
   /* 25 */   { 1,  1, -3, { {       -34e-6,       -26e-6 },
                             {         4e-6,         2e-6 },
                             {       -22e-7,         7e-7 } } },
   /* 26 */   { 1,  1, -2, { {       -43e-6,         1e-6 },
                             {         3e-6,         0e-6 },
                             {        -8e-7,        16e-7 } } },
   /* 27 */   { 1,  1, -1, { {       -15e-6,        21e-6 },
                             {         1e-6,        -1e-6 },
                             {         2e-7,         9e-7 } } },
   /* 28 */   { 1,  1,  0, { {        -1e-6,        15e-6 },
                             {         0e-6,        -2e-6 },
                             {        12e-7,         5e-7 } } },
   /* 29 */   { 1,  1,  1, { {         4e-6,         7e-6 },
                             {         1e-6,         0e-6 },
                             {         1e-7,        -3e-7 } } },
   /* 30 */   { 1,  1,  3, { {         1e-6,         5e-6 },
                             {         1e-6,        -1e-6 },
                             {         1e-7,         0e-7 } } },
   /* 31 */   { 2,  0, -6, { {         8e-6,         3e-6 },
                             {        -2e-6,        -3e-6 },
                             {         9e-7,         5e-7 } } },
   /* 32 */   { 2,  0, -5, { {        -3e-6,         6e-6 },
                             {         1e-6,         2e-6 },
                             {         2e-7,        -1e-7 } } },
   /* 33 */   { 2,  0, -4, { {         6e-6,       -13e-6 },
                             {        -8e-6,         2e-6 },
                             {        14e-7,        10e-7 } } },
   /* 34 */   { 2,  0, -3, { {        10e-6,        22e-6 },
                             {        10e-6,        -7e-6 },
                             {       -65e-7,        12e-7 } } },
   /* 35 */   { 2,  0, -2, { {       -57e-6,       -32e-6 },
                             {         0e-6,        21e-6 },
                             {       126e-7,      -233e-7 } } },
   /* 36 */   { 2,  0, -1, { {       157e-6,       -46e-6 },
                             {         8e-6,         5e-6 },
                             {       270e-7,      1068e-7 } } },
   /* 37 */   { 2,  0,  0, { {        12e-6,       -18e-6 },
                             {        13e-6,        16e-6 },
                             {       254e-7,       155e-7 } } },
   /* 38 */   { 2,  0,  1, { {        -4e-6,         8e-6 },
                             {        -2e-6,        -3e-6 },
                             {       -26e-7,        -2e-7 } } },
   /* 39 */   { 2,  0,  2, { {        -5e-6,         0e-6 },
                             {         0e-6,         0e-6 },
                             {         7e-7,         0e-7 } } },
   /* 40 */   { 2,  0,  3, { {         3e-6,         4e-6 },
                             {         0e-6,         1e-6 },
                             {       -11e-7,         4e-7 } } },
   /* 41 */   { 3,  0, -2, { {        -1e-6,        -1e-6 },
                             {         0e-6,         1e-6 },
                             {         4e-7,       -14e-7 } } },
   /* 42 */   { 3,  0, -1, { {         6e-6,        -3e-6 },
                             {         0e-6,         0e-6 },
                             {        18e-7,        35e-7 } } },
   /* 43 */   { 3,  0,  0, { {        -1e-6,        -2e-6 },
                             {         0e-6,         1e-6 },
                             {        13e-7,         3e-7 } } } };



/* Validate the planet number. */
   if ( np < 1 || np > 9 ) {
      *jstat = -1;
      for ( i = 0; i <= 5; i++ ) pv[i] = 0.0;
      return;
   } else {
      ip = np - 1;
   }

/* Separate algorithms for Pluto and the rest. */
   if ( np != 9 ) {

   /* ----------------------- */
   /* Mercury through Neptune */
   /* ----------------------- */

   /* Time: Julian millennia since J2000. */
      t = ( date - 51544.5 ) / 365250.0;

   /* OK status unless remote epoch. */
      *jstat = ( fabs ( t ) <= 1.0 ) ? 0 : 1;

   /* Compute the mean elements. */
      da = a[ip][0] + ( a[ip][1] + a[ip][2] * t ) * t;
      dl = ( 3600.0 * dlm[ip][0] + ( dlm[ip][1] + dlm[ip][2] * t ) * t )
                                                                  * DAS2R;
      de = e[ip][0] + ( e[ip][1] + e[ip][2] * t ) * t;
      dpe = dmod ( ( 3600.0 * pi[ip][0] + ( pi[ip][1] + pi[ip][2] * t ) * t )
                                                              * DAS2R,D2PI );
      di = ( 3600.0 * dinc[ip][0] + ( dinc[ip][1] + dinc[ip][2] * t ) * t )
                                                                     * DAS2R;
      dom = dmod( ( 3600.0 * omega[ip][0] + ( omega[ip][1]
                                  + omega[ip][2] * t ) * t ) * DAS2R, D2PI );

   /* Apply the trigonometric terms. */
      dmu = 0.35953620 * t;
      for ( j = 0; j <= 7; j++ ) {
         arga = dkp[ip][j] * dmu;
         argl = dkq[ip][j] * dmu;
         da += ( ca[ip][j] * cos ( arga ) +
                 sa[ip][j] * sin ( arga ) ) * 1e-7;
         dl += ( clo[ip][j] * cos ( argl ) +
                 slo[ip][j] * sin ( argl ) ) * 1e-7;
      }
      arga = dkp[ip][8] * dmu;
      da += t * ( ca[ip][8] * cos ( arga ) +
                  sa[ip][8] * sin ( arga ) ) * 1e-7;
      for ( j = 8; j <= 9; j++ ) {
         argl = dkq[ip][j] * dmu;
         dl += t * ( clo[ip][j] * cos ( argl ) +
                     slo[ip][j] * sin ( argl ) ) * 1e-7;
      }
      dl = dmod ( dl, D2PI );

   /* Daily motion. */
      dm = GCON * sqrt ( ( 1.0 + 1.0 / amas[ip] ) / ( da * da * da ) );

   /* Make the prediction. */
      slaPlanel ( date, 1, date, di, dom, dpe, da, de, dl, dm, pv, &j );
      if ( j < 0 ) *jstat = -2;


   } else {

   /* ----- */
   /* Pluto */
   /* ----- */

   /* Time: Julian centuries since J2000. */
      t = ( date - 51544.5 ) / 36525.0;

   /* OK status unless remote epoch. */
      *jstat = t >= -1.15 && t <= 1.0 ? 0 : -1;

   /* Fundamental arguments (radians). */
      dj = ( dj0 + djd * t ) * DD2R;
      ds = ( ds0 + dsd * t ) * DD2R;
      dp = ( dp0 + dpd * t ) * DD2R;

   /* Initialize coefficients and derivatives. */
      for ( i = 0; i < 3; i++ ) {
         wlbr[i] = 0.0;
         wlbrd[i] = 0.0;
      }

   /* Term by term through Meeus Table 36.A. */
      for ( j = 0; j < ( sizeof term / sizeof term[0] ); j++ ) {

      /* Argument and derivative (radians, radians per century). */
         wj = (double) ( term[j].ij );
         ws = (double) ( term[j].is );
         wp = (double) ( term[j].ip );
         al = wj * dj + ws * ds + wp * dp;
         ald = ( wj * djd + ws * dsd + wp * dpd ) * DD2R;

      /* Functions of argument. */
         sal = sin ( al );
         cal = cos ( al );

      /* Periodic terms in longitude, latitude, radius vector. */
         for ( i = 0; i < 3; i++ ) {

         /* A and B coefficients (deg, AU). */
            ac = term[j].dlbr[i].a;
            bc = term[j].dlbr[i].b;

         /* Periodic terms (deg, AU, deg/Jc, AU/Jc). */
            wlbr[i] = wlbr[i] + ac * sal + bc * cal;
            wlbrd[i] = wlbrd[i] + ( ac * cal - bc * sal ) * ald;
         }
      }

   /* Heliocentric longitude and derivative (radians, radians/sec). */
      dl = ( dl0 + dld0 * t + wlbr[0] ) * DD2R;
      dld = ( dld0 + wlbrd[0] ) * DD2R / SPC;

   /* Heliocentric latitude and derivative (radians, radians/sec). */
      db = ( db0 + wlbr[1] ) * DD2R;
      dbd = wlbrd[1] * DD2R / SPC;

   /* Heliocentric radius vector and derivative (AU, AU/sec). */
      dr = dr0 + wlbr[2];
      drd = wlbrd[2] / SPC;

   /* Functions of latitude, longitude, radius vector. */
      sl = sin ( dl );
      cl = cos ( dl );
      sb = sin ( db );
      cb = cos ( db );
      slcb = sl * cb;
      clcb = cl * cb;

   /* Heliocentric vector and derivative, J2000 ecliptic and equinox. */
      x = dr * clcb;
      y = dr * slcb;
      z = dr * sb;
      xd = drd * clcb - dr * ( cl * sb * dbd + slcb * dld );
      yd = drd * slcb + dr * ( - sl * sb * dbd + clcb * dld );
      zd = drd * sb + dr * cb * dbd;

   /* Transform to J2000 equator and equinox. */
      pv[0] = x;
      pv[1] = y * CE - z * SE;
      pv[2] = y * SE + z * CE;
      pv[3] = xd;
      pv[4] = yd * CE - zd * SE;
      pv[5] = yd * SE + zd * CE;
   }
}
예제 #8
0
파일: nutc.c 프로젝트: snfraser/astrolib
void slaNutc ( double date, double *dpsi, double *deps, double *eps0 )
/*
**  - - - - - - - -
**   s l a N u t c
**  - - - - - - - -
**
**  Nutation:  longitude & obliquity components and
**             mean obliquity (IAU 1980 theory).
**
**  (double precision)
**
**  References:
**     Final report of the IAU working group on nutation,
**      chairman P.K.Seidelmann, 1980.
**     Kaplan,G.H., 1981, USNO circular No. 163, pa3-6.
**
**  Given:
**     date        double    TDB (loosely ET) as Modified Julian Date
**                                            (JD-2400000.5)
**
**  Returned:
**     *dpsi,*deps double    nutation in longitude,obliquity
**     *eps0       double    mean obliquity
**
**  Called:  slaDrange
**
**  Defined in slamac.h:  DAS2R, dmod
**
**  Last revision:   19 March 1996
**
**  Copyright P.T.Wallace.  All rights reserved.
*/

#define T2AS 1296000.0                /* Turns to arc seconds */
#define U2R 0.4848136811095359949e-9  /* Units of 0.0001 arcsec to radians */

{
   double t, el, el2, el3, elp, elp2,
          f, f2, f4,
          d, d2, d4,
          om, om2,
          dp, de, a;

/* Interval between basic epoch J2000.0 and current epoch (JC) */
   t = ( date - 51544.5 ) / 36525.0;

/* Fundamental arguments in the FK5 reference system */

/* Mean longitude of the Moon minus mean longitude of the Moon's perigee */
   el = slaDrange ( DAS2R * dmod ( 485866.733 + ( 1325.0 * T2AS + 715922.633
                               + ( 31.310 + 0.064 * t ) * t ) * t , T2AS ) );

/* Mean longitude of the Sun minus mean longitude of the Sun's perigee */
   elp = slaDrange ( DAS2R * dmod ( 1287099.804 + ( 99.0 * T2AS + 1292581.224
                                + ( -0.577 - 0.012 * t ) * t ) * t, T2AS ) );

/* Mean longitude of the Moon minus mean longitude of the Moon's node */
   f = slaDrange ( DAS2R * dmod ( 335778.877 + ( 1342.0 * T2AS + 295263.137
                              + ( -13.257 + 0.011 * t ) * t ) * t, T2AS ) );

/* Mean elongation of the Moon from the Sun */
   d = slaDrange ( DAS2R * dmod ( 1072261.307 + ( 1236.0 * T2AS + 1105601.328
                              + ( -6.891 + 0.019 * t ) * t ) * t, T2AS ) );

/* Longitude of the mean ascending node of the lunar orbit on the
   ecliptic, measured from the mean equinox of date */
   om = slaDrange ( DAS2R * dmod ( 450160.280 + ( -5.0 * T2AS - 482890.539
                               + ( 7.455 + 0.008 * t ) * t ) * t, T2AS ) );

/* Multiples of arguments */
   el2 = el + el;
   el3 = el2 + el;
   elp2 = elp + elp;
   f2 = f + f;
   f4 = f2 + f2;
   d2 = d + d;
   d4 = d2 + d2;
   om2 = om + om;

/* Series for the nutation */
   dp = 0.0;
   de = 0.0;

   dp += sin ( elp + d );                          /* 106  */

   dp -= sin ( f2 + d4 + om2 );                    /* 105  */

   dp += sin ( el2 + d2 );                         /* 104  */

   dp -= sin ( el - f2 + d2 );                     /* 103  */

   dp -= sin ( el + elp - d2 + om );               /* 102  */

   dp -= sin ( - elp + f2 + om );                  /* 101  */

   dp -= sin ( el - f2 - d2 );                     /* 100  */

   dp -= sin ( elp + d2 );                         /*  99  */

   dp -= sin ( f2 - d + om2 );                     /*  98  */

   dp -= sin ( - f2 + om );                        /*  97  */

   dp += sin ( - el - elp + d2 + om );             /*  96  */

   dp += sin ( elp + f2 + om );                    /*  95  */

   dp -= sin ( el + f2 - d2 );                     /*  94  */

   dp += sin ( el3 + f2 - d2 + om2 );              /*  93  */

   dp += sin ( f4 - d2 + om2 );                    /*  92  */

   dp -= sin ( el + d2 + om );                     /*  91  */

   dp -= sin ( el2 + f2 + d2 + om2 );              /*  90  */

   a = el2 + f2 - d2 + om;                         /*  89  */
   dp += sin ( a );
   de -= cos ( a );

   dp += sin ( el - elp - d2 );                    /*  88  */

   dp += sin ( - el + f4 + om2 );                  /*  87  */

   a = - el2 + f2 + d4 + om2;                      /*  86  */
   dp -= sin ( a );
   de += cos ( a );

   a  = el + f2 + d2 + om;                         /*  85  */
   dp -= sin ( a );
   de += cos ( a );

   a = el + elp + f2 - d2 + om2;                   /*  84  */
   dp += sin ( a );
   de -= cos ( a );

   dp -= sin ( el2 - d4 );                         /*  83  */

   a = - el + f2 + d4 + om2;                       /*  82  */
   dp -= 2.0 * sin ( a );
   de += cos ( a );

   a = - el2 + f2 + d2 + om2;                      /*  81  */
   dp += sin ( a );
   de = de - cos ( a );

   dp -= sin ( el - d4 );                          /*  80  */

   a = - el + om2;                                 /*  79  */
   dp += sin ( a );
   de = de - cos ( a );

   a = f2 + d + om2;                               /*  78  */
   dp += 2.0 * sin ( a );
   de = de - cos ( a );

   dp += 2.0 * sin ( el3 );                        /*  77  */

   a = el + om2;                                   /*  76  */
   dp -= 2.0 * sin ( a );
   de += cos ( a );

   a = el2 + om;                                   /*  75  */
   dp += 2.0 * sin ( a );
   de -= cos ( a );

   a = - el + f2 - d2 + om;                        /*  74  */
   dp -= 2.0 * sin ( a );
   de += cos ( a );

   a = el + elp + f2 + om2;                        /*  73  */
   dp += 2.0 * sin ( a );
   de = de - cos ( a );

   a = - elp + f2 + d2 + om2;                      /*  72  */
   dp -= 3.0 * sin ( a );
   de += cos ( a );

   a = el3 + f2 + om2;                             /*  71  */
   dp -= 3.0 * sin ( a );
   de += cos ( a );

   a = - el2 + om;                                 /*  70  */
   dp -= 2.0 * sin ( a );
   de += cos ( a );

   a = - el - elp + f2 + d2 + om2;                 /*  69  */
   dp -= 3.0 * sin ( a );
   de += cos ( a );

   a = el - elp + f2 + om2;                        /*  68  */
   dp -= 3.0 * sin ( a );
   de += cos ( a );

   dp += 3.0 * sin ( el + f2 );                    /*  67  */

   dp -= 3.0 * sin ( el + elp );                   /*  66  */

   dp -= 4.0 * sin ( d );                          /*  65  */

   dp += 4.0 * sin ( el - f2 );                    /*  64  */

   dp -= 4.0 * sin ( elp - d2 );                   /*  63  */

   a = el2 + f2 + om;                              /*  62  */
   dp -= 5.0 * sin ( a );
   de += 3.0 * cos ( a );

   dp += 5.0 * sin ( el - elp );                   /*  61  */

   a = - d2 + om;                                  /*  60  */
   dp -= 5.0 * sin ( a );
   de += 3.0 * cos ( a );

   a = el + f2 - d2 + om;                          /*  59  */
   dp += 6.0 * sin ( a );
   de -= 3.0 * cos ( a );

   a = f2 + d2 + om;                               /*  58  */
   dp -= 7.0 * sin ( a );
   de += 3.0 * cos ( a );

   a = d2 + om;                                    /*  57  */
   dp -= 6.0 * sin ( a );
   de += 3.0 * cos ( a );

   a = el2 + f2 - d2 + om2;                        /*  56  */
   dp += 6.0 * sin ( a );
   de -= 3.0 * cos ( a );

   dp += 6.0 * sin ( el + d2);                     /*  55  */

   a = el + f2 + d2 + om2;                         /*  54  */
   dp -= 8.0 * sin ( a );
   de += 3.0 * cos ( a );

   a = - elp + f2 + om2;                           /*  53  */
   dp -= 7.0 * sin ( a );
   de += 3.0 * cos ( a );

   a = elp + f2 + om2;                             /*  52  */
   dp += 7.0 * sin ( a );
   de -= 3.0 * cos ( a );

   dp -= 7.0 * sin ( el + elp - d2 );              /*  51  */

   a = - el + f2 + d2 + om;                        /*  50  */
   dp -= 10.0 * sin ( a );
   de += 5.0 * cos ( a );

   a = el - d2 + om;                               /*  49  */
   dp -= 13.0 * sin ( a );
   de += 7.0 * cos ( a );

   a = - el + d2 + om;                             /*  48  */
   dp += 16.0 * sin ( a );
   de -= 8.0 * cos ( a );

   a = - el + f2 + om;                             /*  47  */
   dp += 21.0 * sin ( a );
   de -= 10.0 * cos ( a );

   dp += 26.0 * sin ( f2 );                        /*  46  */
   de -= cos( f2 );

   a = el2 + f2 + om2;                             /*  45  */
   dp -= 31.0 * sin ( a );
   de += 13.0 * cos ( a );

   a = el + f2 - d2 + om2;                         /*  44  */
   dp += 29.0 * sin ( a );
   de -= 12.0 * cos ( a );

   dp += 29.0 * sin ( el2 );                       /*  43  */
   de -= cos( el2 );

   a = f2 + d2 + om2;                              /*  42  */
   dp -= 38.0 * sin ( a );
   de += 16.0 * cos ( a );

   a = el + f2 + om;                               /*  41  */
   dp -= 51.0 * sin ( a );
   de += 27.0 * cos ( a );

   a = - el + f2 + d2 + om2;                       /*  40  */
   dp -= 59.0 * sin ( a );
   de += 26.0 * cos ( a );

   a = - el + om;                                  /*  39  */
   dp += ( - 58.0 -  0.1 * t ) * sin ( a );
   de += 32.0 * cos ( a );

   a = el + om;                                    /*  38  */
   dp += ( 63.0 + 0.1 * t ) * sin ( a );
   de -= 33.0 * cos ( a );

   dp += 63.0 * sin ( d2 );                        /*  37  */
   de -= 2.0 * cos( d2 );

   a = - el + f2 + om2;                            /*  36  */
   dp += 123.0 * sin ( a );
   de -= 53.0 * cos ( a );

   a = el - d2;                                    /*  35  */
   dp -= 158.0 * sin ( a );
   de -= cos ( a );

   a = el + f2 + om2;                              /*  34  */
   dp -= 301.0 * sin ( a );
   de += ( 129.0 - 0.1 * t ) * cos ( a );

   a = f2 + om;                                    /*  33  */
   dp += ( - 386.0 - 0.4 * t ) * sin ( a );
   de += 200.0 * cos ( a );

   dp += ( 712.0 + 0.1 * t ) * sin ( el );         /*  32  */
   de -= 7.0 * cos( el );

   a = f2 + om2;                                   /*  31  */
   dp += ( -2274.0 - 0.2 * t ) * sin ( a );
   de += ( 977.0 - 0.5 * t ) * cos ( a );

   dp -= sin ( elp + f2 - d2 );                    /*  30  */

   dp += sin ( - el + d + om );                    /*  29  */

   dp += sin ( elp + om2 );                        /*  28  */

   dp -= sin ( elp - f2 + d2 );                    /*  27  */

   dp += sin ( - f2 + d2 + om );                   /*  26  */

   dp += sin ( el2 + elp - d2 );                   /*  25  */

   dp -= 4.0 * sin ( el - d );                     /*  24  */

   a = elp + f2 - d2 + om;                         /*  23  */
   dp += 4.0 * sin ( a );
   de -= 2.0 * cos ( a );

   a = el2 - d2 + om;                              /*  22  */
   dp += 4.0 * sin ( a );
   de -= 2.0 * cos ( a );

   a = - elp + f2 - d2 + om;                       /*  21  */
   dp -= 5.0 * sin ( a );
   de += 3.0 * cos ( a );

   a = - el2 + d2 + om;                            /*  20  */
   dp -= 6.0 * sin ( a );
   de += 3.0 * cos ( a );

   a = - elp + om;                                 /*  19  */
   dp -= 12.0 * sin ( a );
   de += 6.0 * cos ( a );

   a = elp2 + f2 - d2 + om2;                       /*  18  */
   dp += ( - 16.0 + 0.1 * t) * sin ( a );
   de += 7.0 * cos ( a );

   a = elp + om;                                   /*  17  */
   dp -= 15.0 * sin ( a );
   de += 9.0 * cos ( a );

   dp += ( 17.0 - 0.1 * t ) * sin ( elp2 );        /*  16  */

   dp -= 22.0 * sin ( f2 - d2 );                   /*  15  */

   a = el2 - d2;                                   /*  14  */
   dp += 48.0 * sin ( a );
   de += cos ( a );

   a = f2 - d2 + om;                               /*  13  */
   dp += ( 129.0 + 0.1 * t ) * sin ( a );
   de -= 70.0 * cos ( a );

   a = - elp + f2 - d2 + om2;                      /*  12  */
   dp += ( 217.0 - 0.5 * t ) * sin ( a );
   de += ( -95.0 + 0.3 * t ) * cos ( a );

   a = elp + f2 - d2 + om2;                        /*  11  */
   dp += ( - 517.0 + 1.2 * t ) * sin ( a );
   de += ( 224.0 - 0.6 * t ) * cos ( a );

   dp += ( 1426.0 - 3.4 * t ) * sin ( elp );       /*  10  */
   de += ( 54.0 - 0.1 * t) * cos ( elp );

   a = f2 - d2 + om2;                              /*   9  */
   dp += ( - 13187.0 - 1.6 * t ) * sin ( a );
   de += ( 5736.0 - 3.1 * t ) * cos ( a );

   dp += sin ( el2 - f2 + om );                    /*   8  */

   a = - elp2 + f2 - d2 + om;                      /*   7  */
   dp -= 2.0 * sin ( a );
   de +=       cos ( a );

   dp -= 3.0 * sin ( el - elp - d );               /*   6  */

   a = - el2 + f2 + om2;                           /*   5  */
   dp -= 3.0 * sin ( a );
   de +=       cos ( a );

   dp += 11.0 * sin ( el2 - f2 );                  /*   4  */

   a = - el2 + f2 + om;                            /*   3  */
   dp += 46.0 * sin ( a );
   de -= 24.0 * cos ( a );

   dp += ( 2062.0 + 0.2 * t ) * sin ( om2 );       /*   2  */
   de += ( - 895.0 + 0.5 * t ) * cos ( om2 );

   dp += ( - 171996.0 - 174.2 * t) * sin ( om );   /*   1  */
   de += ( 92025.0 + 8.9 * t ) * cos ( om );

/* Convert results to radians */
   *dpsi = dp * U2R;
   *deps = de * U2R;

/* Mean obliquity */
   *eps0 = DAS2R * ( 84381.448 +
                   ( - 46.8150 +
                   ( - 0.00059 + 0.001813 * t ) * t ) * t );
}
예제 #9
0
파일: gmsta.c 프로젝트: Starlink/starlink
double sbmgmsta(double qfoo,double qbar){double qbaz,Q0,
qfobar;if(qfoo<qbar){qbaz=qfoo;Q0=qbar;}else{qbaz=qbar;Q0=
qfoo;}qfobar=(qbaz+(Q0-51544.5))/36525.0;return sbmdranrm(
DS2R*(24110.54841+(8640184.812866+(0.093104-6.2e-6*qfobar)*
qfobar)*qfobar+86400.0*(dmod(qbaz,1.0)+dmod(Q0,1.0))));}
예제 #10
0
파일: dranrm.c 프로젝트: Starlink/starlink
double sbmdranrm(double qfoo){double qbar;qbar=dmod(qfoo,
D2PI);return(qbar>=0.0)?qbar:qbar+D2PI;}
예제 #11
0
파일: moon.c 프로젝트: chopley/controlCode
void slaMoon ( int iy, int id, float fd, float pv[6] )
/*
**  - - - - - - - -
**   s l a M o o n
**  - - - - - - - -
**
**  Approximate geocentric position and velocity of the Moon
**  (single precision).
**
**  Given:
**     iy       int        year
**     id       int        day in year (1 = Jan 1st)
**     fd       float      fraction of day
**
**  Returned:
**     pv       float[6]   Moon position & velocity vector
**
**  Notes:
**
**  1  The date and time is TDB (loosely ET) in a Julian calendar
**     which has been aligned to the ordinary Gregorian
**     calendar for the interval 1900 March 1 to 2100 February 28.
**     The year and day can be obtained by calling slaCalyd or
**     slaClyd.
**
**  2  The Moon 6-vector is Moon centre relative to Earth centre,
**     mean equator and equinox of date.  Position part, pv[0-2],
**     is in AU;  velocity part, pv[3-5], is in AU/sec.
**
**  3  The position is accurate to better than 0.5 arcminute
**     in direction and 1000 km in distance.  The velocity
**     is accurate to better than 0.5"/hour in direction and
**     4 m/s in distance.  (RMS figures with respect to JPL DE200
**     for the interval 1960-2025 are 14 arcsec and 0.2 arcsec/hour in
**     longitude, 9 arcsec and 0.2 arcsec/hour in latitude, 350 km and
**     2 m/s in distance.)  Note that the distance accuracy is
**     comparatively poor because this routine is principally intended
**     for computing topocentric direction.
**
**  4  This routine is only a partial implementation of the original
**     Meeus algorithm (reference below), which offers 4 times the
**     accuracy in direction and 30 times the accuracy in distance
**     when fully implemented (as it is in slaDmoon).
**
**  Reference:
**     Meeus, l'Astronomie, June 1984, p348.
**
**  Defined in slamac.h:  dmod
**
**  Last revision:   19 March 1996
**
**  Copyright P.T.Wallace.  All rights reserved.
*/

#define D2R 0.01745329252f            /* Degrees to radians            */

#define RATCON 9.652743551e-12f       /* Rate conversion factor:       */
                                      /* D2R * D2R / (86400 * 365.25)  */

#define ERADAU 4.2635212653763e-5f    /* Earth equatorial radius in AU */
                                      /*   ( = 6378.137 / 149597870 )  */

{
   int iy4, n;
   float yi, yf, t, elp, em, emp, d, f, v, dv, emn, empn, dn, fn, coeff,
         theta, el, del, b, db, p, dp, sp, r, dr, x, y, z, xd, yd, zd,
         sel, cel, sb, cb, rcb, rbd, w, eps, sineps, coseps;

/*
**  Coefficients for fundamental arguments
**
**  Fixed term (deg), term in t (deg & whole revs + fraction per year)
**
**  Moon's mean longitude
*/
   static float elp0  = 270.434164f;
   static float elp1  = 4812.678831f;
   static float elp1i = 4680.0f;
   static float elp1f = 132.678831f;

/* Sun's mean anomaly */
   static float em0  = 358.475833f;
   static float em1  = 359.990498f;
   static float em1f = 359.990498f;

/* Moon's mean anomaly */
   static float emp0  = 296.104608f;
   static float emp1  = 4771.988491f;
   static float emp1i = 4680.0f;
   static float emp1f = 91.988491f;

/* Moon's mean elongation */
   static float d0 = 350.737486f;
   static float d1 = 4452.671142f;
   static float d1i = 4320.0f;
   static float d1f = 132.671142f;

/* Mean distance of the Moon from its ascending node */
   static float f0 = 11.250889f;
   static float f1 = 4832.020251f;
   static float f1i = 4680.0f;
   static float f1f = 152.020251f;

/*
**  Coefficients for Moon longitude, latitude, parallax series
*/
   struct term {
      float coef;      /* coefficient of L, B or P term (deg) */
      int nem;         /* multiple of M  in argument          */
      int nemp;        /*     "    "  M'  "    "              */
      int nd;          /*     "    "  D   "    "              */
      int nf;          /*     "    "  F   "    "              */
   };

/*
** Longitude                      coeff       M    M'   D    F
*/
   static struct term tl[] = { {  6.288750f,    0,   1,   0,   0 },
                               {  1.274018f,    0,  -1,   2,   0 },
                               {  0.658309f,    0,   0,   2,   0 },
                               {  0.213616f,    0,   2,   0,   0 },
                               { -0.185596f,    1,   0,   0,   0 },
                               { -0.114336f,    0,   0,   0,   2 },
                               {  0.058793f,    0,  -2,   2,   0 },
                               {  0.057212f,   -1,  -1,   2,   0 },
                               {  0.053320f,    0,   1,   2,   0 },
                               {  0.045874f,   -1,   0,   2,   0 },
                               {  0.041024f,   -1,   1,   0,   0 },
                               { -0.034718f,    0,   0,   1,   0 },
                               { -0.030465f,    1,   1,   0,   0 },
                               {  0.015326f,    0,   0,   2,  -2 },
                               { -0.012528f,    0,   1,   0,   2 },
                               { -0.010980f,    0,  -1,   0,   2 },
                               {  0.010674f,    0,  -1,   4,   0 },
                               {  0.010034f,    0,   3,   0,   0 },
                               {  0.008548f,    0,  -2,   4,   0 },
                               { -0.007910f,    1,  -1,   2,   0 },
                               { -0.006783f,    1,   0,   2,   0 },
                               {  0.005162f,    0,   1,  -1,   0 },
                               {  0.005000f,    1,   0,   1,   0 },
                               {  0.004049f,   -1,   1,   2,   0 },
                               {  0.003996f,    0,   2,   2,   0 },
                               {  0.003862f,    0,   0,   4,   0 },
                               {  0.003665f,    0,  -3,   2,   0 },
                               {  0.002695f,   -1,   2,   0,   0 },
                               {  0.002602f,    0,   1,  -2,  -2 },
                               {  0.002396f,   -1,  -2,   2,   0 },
                               { -0.002349f,    0,   1,   1,   0 },
                               {  0.002249f,   -2,   0,   2,   0 },
                               { -0.002125f,    1,   2,   0,   0 },
                               { -0.002079f,    2,   0,   0,   0 },
                               {  0.002059f,   -2,  -1,   2,   0 },
                               { -0.001773f,    0,   1,   2,  -2 },
                               { -0.001595f,    0,   0,   2,   2 },
                               {  0.001220f,   -1,  -1,   4,   0 },
                               { -0.001110f,    0,   2,   0,   2 } };
   static int NL = ( sizeof tl / sizeof ( struct term ) );

/*
** Latitude                       coeff       M    M'   D    F
*/
   static struct term tb[] = { {  5.128189f,    0,   0,   0,   1 },
                               {  0.280606f,    0,   1,   0,   1 },
                               {  0.277693f,    0,   1,   0,  -1 },
                               {  0.173238f,    0,   0,   2,  -1 },
                               {  0.055413f,    0,  -1,   2,   1 },
                               {  0.046272f,    0,  -1,   2,  -1 },
                               {  0.032573f,    0,   0,   2,   1 },
                               {  0.017198f,    0,   2,   0,   1 },
                               {  0.009267f,    0,   1,   2,  -1 },
                               {  0.008823f,    0,   2,   0,  -1 },
                               {  0.008247f,   -1,   0,   2,  -1 },
                               {  0.004323f,    0,  -2,   2,  -1 },
                               {  0.004200f,    0,   1,   2,   1 },
                               {  0.003372f,   -1,   0,  -2,   1 },
                               {  0.002472f,   -1,  -1,   2,   1 },
                               {  0.002222f,   -1,   0,   2,   1 },
                               {  0.002072f,   -1,  -1,   2,  -1 },
                               {  0.001877f,   -1,   1,   0,   1 },
                               {  0.001828f,    0,  -1,   4,  -1 },
                               { -0.001803f,    1,   0,   0,   1 },
                               { -0.001750f,    0,   0,   0,   3 },
                               {  0.001570f,   -1,   1,   0,  -1 },
                               { -0.001487f,    0,   0,   1,   1 },
                               { -0.001481f,    1,   1,   0,   1 },
                               {  0.001417f,   -1,  -1,   0,   1 },
                               {  0.001350f,   -1,   0,   0,   1 },
                               {  0.001330f,    0,   0,  -1,   1 },
                               {  0.001106f,    0,   3,   0,   1 },
                               {  0.001020f,    0,   0,   4,  -1 } };
   static int NB = ( sizeof tb / sizeof ( struct term ) );

/*
** Parallax                       coeff       M    M'   D    F
*/
   static struct term tp[] = { {  0.950724f,    0,   0,   0,   0 },
                               {  0.051818f,    0,   1,   0,   0 },
                               {  0.009531f,    0,  -1,   2,   0 },
                               {  0.007843f,    0,   0,   2,   0 },
                               {  0.002824f,    0,   2,   0,   0 } };
   static int NP = ( sizeof tp / sizeof ( struct term ) );



/* Whole years & fraction of year, and years since J1900.0 */
   yi = (float) ( iy - 1900 );
   iy4 = iy >= 4 ? iy % 4 : 3 - ( -iy - 1 ) % 4 ;
   yf = ( (float) ( 4 * ( id - 1 / ( iy4 + 1 ) )
                - iy4 - 2 ) + ( 4.0f * fd ) ) / 1461.0f;
   t  = yi + yf;

/* Moon's mean longitude */
   elp = D2R * (float) dmod ( (double) ( elp0 + elp1i * yf + elp1f * t ),
                                                                  360.0 );

/* Sun's mean anomaly */
   em = D2R * (float) dmod ( (double) ( em0 + em1f * t ), 360.0 );

/* Moon's mean anomaly */
   emp = D2R * (float) dmod ( (double) ( emp0 + emp1i * yf + emp1f * t ),
                                                                  360.0 );

/* Moon's mean elongation */
   d = D2R * (float) dmod ( (double) ( d0 + d1i * yf + d1f * t ), 360.0 );

/* Mean distance of the Moon from its ascending node */
   f = D2R * (float) dmod ( (double) ( f0 + f1i * yf + f1f * t ), 360.0 );

/* Longitude */
   v = 0.0f;
   dv = 0.0f;
   for ( n = NL -1; n >= 0; n-- ) {
      coeff = tl[n].coef;
      emn = (float) tl[n].nem;
      empn = (float) tl[n].nemp;
      dn = (float) tl[n].nd;
      fn = (float) tl[n].nf;
      theta = emn * em + empn * emp + dn * d + fn * f;
      v += coeff * ( (float) sin ( (double) theta ) );
      dv += coeff * ( (float) cos ( (double) theta ) ) *
                    ( emn * em1 + empn * emp1 + dn * d1 + fn * f1 );
   }
   el = elp + D2R * v;
   del = RATCON * ( elp1 / D2R +  dv );

/* Latitude */
   v = 0.0f;
   dv = 0.0f;
   for ( n = NB - 1; n >= 0; n-- ) {
      coeff = tb[n].coef;
      emn = (float) tb[n].nem;
      empn = (float) tb[n].nemp;
      dn = (float) tb[n].nd;
      fn = (float) tb[n].nf;
      theta = emn * em + empn * emp + dn * d + fn * f;
      v += coeff * ( (float) sin ( (double) theta ) );
      dv += coeff * ( (float) cos ( (double) theta ) ) *
                    ( emn * em1 + empn * emp1 + dn * d1 + fn * f1 );
   }
   b = D2R * v;
   db = RATCON * dv;

/* Parallax */
   v = 0.0f;
   dv = 0.0f;
   for ( n = NP - 1; n >= 0; n-- ) {
      coeff = tp[n].coef;
      emn = (float) tp[n].nem;
      empn = (float) tp[n].nemp;
      dn = (float) tp[n].nd;
      fn = (float) tp[n].nf;
      theta = emn * em + empn * emp + dn * d + fn * f;
      v += coeff * ( (float) cos ( (double) theta ) );
      dv += coeff * ( - (float) sin ( (double) theta ) ) *
                    ( emn * em1 + empn * emp1 + dn * d1 + fn * f1 );
   }
   p = D2R * v;
   dp = RATCON * dv;

/* Parallax to distance (AU, AU/sec) */
   sp = (float) sin ( (double) p );
   r = ERADAU / sp;
   dr = - r * dp * cos ( (double) p ) / sp;

/* Longitude, latitude to x, y, z (AU) */
   sel = (float) sin ( (double) el );
   cel = (float) cos ( (double) el );
   sb = (float) sin ( (double) b );
   cb = (float) cos ( (double) b );
   rcb = r * cb;
   rbd = r * db;
   w = rbd * sb - cb * dr;
   x = rcb * cel;
   y = rcb * sel;
   z = r * sb;
   xd = - y * del - w * cel;
   yd = x * del - w * sel;
   zd = rbd * cb + sb * dr;

/* Mean obliquity */
   eps = D2R * ( 23.45229f - 0.00013f * t );
   sineps = (float) sin ( (double) eps );
   coseps = (float) cos ( (double) eps );

/* To the equatorial system, mean of date */
   pv[0] = x;
   pv[1] = y * coseps - z * sineps;
   pv[2] = y * sineps + z * coseps;
   pv[3] = xd;
   pv[4] = yd * coseps - zd * sineps;
   pv[5] = yd * sineps + zd * coseps;
}