V6 fk524(V6 v) { v = m6v6(M, v); /* restore e-terms */ #ifdef ETERMS { double m; /* modulus of position vector */ V3 s0; V3 s1, s1dot; V3 r0, r0dot; V3 r1, r1dot; /* cache the modulus */ m = v6mod(v); /* convert the state vector back to a unit vector */ v6GetPos(v) = v3scale(v6GetPos(v), 1/m); v6GetVel(v) = v3scale(v6GetVel(v), CB/(m*as2r(1))); /* now proceed with the standard treatment */ r1 = v6GetPos(v); r1dot = v6GetVel(v); s1 = v3unit(r1); s0 = s1; r0 = v3sum(s1, v3diff(A, v3scale(s0, v3dot(s0, A)))); #ifdef ETERMS_ITERATE s0 = v3unit(r0); r0 = v3sum(s1, v3diff(A, v3scale(s0, v3dot(s0, A)))); #endif v6SetPos(v, r0); #ifdef ETERMS_VEL s1dot = v3scale(r1dot, 1/v3mod(r1)); r0dot = v3sum(s1dot, v3diff(Adot, v3scale(s0, v3dot(s0, Adot)))); v6SetVel(v, r0dot); #endif /* convert the unit vector back into a state vector */ v6GetPos(v) = v3scale(v6GetPos(v), m); v6GetVel(v) = v3scale(v6GetVel(v), (m*as2r(1))/CB); } #endif return(v); }
V6 cat2v6r1(double r, double d, double rd, double dd, double px, double rv, double C) { V6 v6; /* the state vector */ double m; /* vector modulus */ /* get the vector the ES way, and scale it manually */ v6 = cat2v6u2(r, d, rd, dd, px, rv, C); if (px > 0.001) { m = 1 / as2r(px); v6GetPos(v6) = v3scale(v6GetPos(v6), m); v6GetVel(v6) = v3scale(v6GetVel(v6), m*as2r(1)/C); } else { m = 1e10; v6GetPos(v6) = v3scale(v6GetPos(v6), m); v6GetVel(v6) = v3scale(v6GetVel(v6), m*as2r(1)/C); } return(v6); }
V6 fk425(V6 v) { /* ensure cartesian vectors */ v = v6s2c(v); #ifdef ETERMS { double m; /* modulus of position vector */ V3 u0, u0dot; V3 u1, u1dot; /* cache the modulus */ m = v6mod(v); /* convert the state vector back to a unit vector */ v6GetPos(v) = v3scale(v6GetPos(v), 1/m); v6GetVel(v) = v3scale(v6GetVel(v), CB/(m*as2r(1))); /* now proceed with the standard treatment */ u0 = v6GetPos(v); u1 = v3diff(u0, v3diff(A, v3scale(u0, v3dot(u0, A)))); v6SetPos(v, u1); #ifdef ETERMS_VEL u0dot = v6GetVel(v); u1dot = v3diff(u0dot, v3diff(Adot, v3scale(u0, v3dot(u0, Adot)))); v6SetVel(v, u1dot); #endif /* convert the unit vector back into a state vector */ v6GetPos(v) = v3scale(v6GetPos(v), m); v6GetVel(v) = v3scale(v6GetVel(v), (m*as2r(1))/CB); } #endif v = m6v6(M, v); return(v); }
void nutations(double tdt, double *delta_phi, double *delta_eps) { double D; double F; double T; /* elapsed julian centuries */ double deps; /* nutation in obliquity */ double dphi; /* nutation in longitude */ double lm; double ls; double omega; int i; #ifdef PLANETARY_TERMS double V; /* venus */ double S; /* saturn */ double Q; /* mercury */ double M; /* moon */ double J; /* jupiter */ double E; /* earth */ #endif T = (tdt - J2000) / 36525; /* in arcseconds */ omega = 450160.280 + (T * (-482890.539 + (T * (7.455 + (T * 0.008))))); /* convert to radians */ omega = as2r(omega); /* add in whole revs */ omega -= 5.0 * 2 * M_PI * T; /* in arcseconds */ lm = 485866.733 + (T * (715922.633 + (T * (31.310 + (T * 0.064))))); /* convert to radians */ lm = as2r(lm); /* add in whole revs */ lm += 1325.0 * 2 * M_PI * T; /* in arcseconds */ ls = 1287099.804 + (T * (1292581.244 + (T * (-0.577 + (T * -0.012))))); /* convert to radians */ ls = as2r(ls); /* add in whole revs */ ls += 99.0 * 2 * M_PI * T; /* in arcseconds */ F = 335778.877 + (T * (295263.137 + (T * (-13.257 + (T * 0.011))))); /* convert to radians */ F = as2r(F); /* add in whole revs */ F += 1342.0 * 2 * M_PI * T; /* in arcseconds */ D = 1072261.307 + (T * (1105601.328 + (T * (-6.891 + (T * 0.019))))); /* convert to radians */ D = as2r(D); /* add in whole revs */ D += 1236.0 * 2 * M_PI * T; /**************************/ /* initialize the outputs */ /**************************/ *delta_phi = 0.0; *delta_eps = 0.0; /*********************/ /* do the IAU theory */ /*********************/ dphi = 0.0; deps = 0.0; for (i = 0; i < N_IAU; i++) { double angle; angle = 0.0; angle += iau[i].lm * lm; angle += iau[i].ls * ls; angle += iau[i].F * F; angle += iau[i].D * D; angle += iau[i].omega * omega; dphi += (iau[i].S0 + (T * iau[i].S1)) * sin(angle); deps += (iau[i].C0 + (T * iau[i].C1)) * cos(angle); } /* convert to arcseconds */ dphi *= 1e-4; deps *= 1e-4; /* convert to radians */ dphi = as2r(dphi); deps = as2r(deps); /* add this contribution */ *delta_phi += dphi; *delta_eps += deps; #ifdef IAU_CORRECTIONS /**************************/ /* do the IAU corrections */ /**************************/ dphi = 0.0; deps = 0.0; for (i = 0; i < N_BIH; i++) { double angle; angle = 0.0; angle += bih[i].lm * lm; angle += bih[i].ls * ls; angle += bih[i].F * F; angle += bih[i].D * D; angle += bih[i].omega * omega; dphi += bih[i].LS * sin(angle) + bih[i].LC * cos(angle); deps += bih[i].OC * cos(angle) + bih[i].OS * sin(angle); } /* convert to arcseconds */ dphi *= 1e-5; deps *= 1e-5; /* convert to radians */ dphi = as2r(dphi); deps = as2r(deps); /* add this contribution */ *delta_phi += dphi; *delta_eps += deps; #endif #ifdef PLANETARY_TERMS /**************************/ /* do the planetary terms */ /**************************/ Q = d2r(252.3 + T * 149472.7); V = d2r(179.9 + T * 58517.8); E = d2r(98.4 + T * 35999.4); M = d2r(353.3 + T * 19140.3); J = d2r(32.3 + T * 3034.9); S = d2r(48.0 + T * 1222.1); dphi = 0.0; deps = 0.0; for (i = 0; i < N_PLAN; i++) { double angle; angle = 0.0; angle += plan[i].lm * lm; angle += plan[i].F * F; angle += plan[i].D * D; angle += plan[i].omega * omega; angle += plan[i].Q * Q; angle += plan[i].V * V; angle += plan[i].E * E; angle += plan[i].M * M; angle += plan[i].J * J; angle += plan[i].S * S; dphi = plan[i].LS * sin(angle) + plan[i].LC * cos(angle); deps = plan[i].OC * cos(angle) + plan[i].OS * sin(angle); } /* convert to arcseconds */ dphi *= 1e-5; deps *= 1e-5; /* convert to radians */ dphi = as2r(dphi); deps = as2r(deps); /* add this contribution */ *delta_phi += dphi; *delta_eps += deps; #endif return; }
double zetadot(double j1, double j2, int pflag) { double T; double f = CB; /* conversion factor from centuries to days */ double t; double zetadot; switch (pflag) { case PRECESS_NEWCOMB: T = (j1 - BYEAR2JD(1850)) / CB; t = (j2 - j1) / CB; zetadot = 3 * (0.018); zetadot *= t; zetadot += 2 * (0.302); zetadot *= t; zetadot += (2304.250 + ((T-0.5) * (1.396))); break; case PRECESS_ANDOYER: T = (j1 - BYEAR2JD(1850)) / CB; t = (j2 - j1) / CB; zetadot = 3 * (0.017995); zetadot *= t; zetadot += 2 * (0.30240 + (T * (-0.000270))); zetadot *= t; zetadot += (2303.5545 + (T * (1.39720 + (T * (0.000060))))); break; case PRECESS_KINOSHITA: T = (j1 - BYEAR2JD(1850)) / CB; t = (j2 - j1) / CB; zetadot = 3* (0.017996); zetadot *= t; zetadot += 2 * (0.30242 + (T * (-0.000269))); zetadot *= t; zetadot += (2303.5548 + (T * (1.39720 + (T * (0.000059))))); break; case PRECESS_LIESKE: T = (j1 - BYEAR2JD(1850)) / CB; t = (j2 - j1) / CB; zetadot = 3 * (0.0180); zetadot *= t; zetadot += 2 * (0.3023 + ((T-0.5) * (-0.000211))); zetadot *= t; zetadot += (2304.253 + ((T-0.5) * (1.3972 + ((T-0.5) * (0.000125))))); break; case PRECESS_FK5: default: T = (j1 - J2000) / CJ; t = (j2 - j1) / CJ; f = CJ; zetadot = 3 * (0.017998); zetadot *= t; zetadot += 2 * (0.30188 + (T * (-0.000344))); zetadot *= t; zetadot += (2306.2181 + (T * (1.39656 + (T * (-0.000139))))); break; } #ifdef DEBUG (void)fprintf(stdout, "zetadot(%d): %.15e\n", pflag, zetadot); #endif /* convert to radians per day */ zetadot = as2r(zetadot)/f; return(zetadot); }