void eraRxpv(double r[3][3], double pv[2][3], double rpv[2][3]) /* ** - - - - - - - - ** e r a R x p v ** - - - - - - - - ** ** Multiply a pv-vector by an r-matrix. ** ** Given: ** r double[3][3] r-matrix ** pv double[2][3] pv-vector ** ** Returned: ** rpv double[2][3] r * pv ** ** Note: ** It is permissible for pv and rpv to be the same array. ** ** Called: ** eraRxp product of r-matrix and p-vector ** ** Copyright (C) 2013-2014, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { eraRxp(r, pv[0], rpv[0]); eraRxp(r, pv[1], rpv[1]); return; }
void palGalsup ( double dl, double db, double *dsl, double *dsb ) { double v1[3]; double v2[3]; /* * System of supergalactic coordinates: * * SGL SGB L2 B2 (deg) * - +90 47.37 +6.32 * 0 0 - 0 * * Galactic to supergalactic rotation matrix: */ double rmat[3][3] = { { -0.735742574804,+0.677261296414,+0.000000000000 }, { -0.074553778365,-0.080991471307,+0.993922590400 }, { +0.673145302109,+0.731271165817,+0.110081262225 } }; /* Spherical to Cartesian */ eraS2c( dl, db, v1 ); /* Galactic to Supergalactic */ eraRxp( rmat, v1, v2 ); /* Cartesian to spherical */ eraC2s( v2, dsl, dsb ); /* Express in conventional ranges */ *dsl = eraAnp( *dsl ); *dsb = eraAnpm( *dsb ); }
void palEqecl ( double dr, double dd, double date, double *dl, double *db ) { double v1[3], v2[3]; double rmat[3][3]; /* Spherical to Cartesian */ eraS2c( dr, dd, v1 ); /* Mean J2000 to mean of date */ palPrec( 2000.0, palEpj(date), rmat ); eraRxp( rmat, v1, v2 ); /* Equatorial to ecliptic */ palEcmat( date, rmat ); eraRxp( rmat, v2, v1 ); /* Cartesian to spherical */ eraC2s( v1, dl, db ); /* Express in conventional range */ *dl = eraAnp( *dl ); *db = palDrange( *db ); }
void palMapqkz ( double rm, double dm, double amprms[21], double *ra, double *da ){ /* Local Variables: */ int i; double ab1, abv[3], p[3], w, p1dv, p2[3], p3[3]; double gr2e, pde, pdep1, ehn[3], p1[3]; /* Unpack scalar and vector parameters. */ ab1 = amprms[11]; gr2e = amprms[7]; for( i = 0; i < 3; i++ ) { abv[i] = amprms[i+8]; ehn[i] = amprms[i+4]; } /* Spherical to x,y,z. */ eraS2c( rm, dm, p ); /* Light deflection (restrained within the Sun's disc) */ pde = eraPdp( p, ehn ); pdep1 = pde + 1.0; w = gr2e / ( pdep1 > 1.0e-5 ? pdep1 : 1.0e-5 ); for( i = 0; i < 3; i++) { p1[i] = p[i] + w * ( ehn[i] - pde * p[i] ); } /* Aberration. */ p1dv = eraPdp( p1, abv ); w = 1.0 + p1dv / ( ab1 + 1.0 ); for( i = 0; i < 3; i++ ) { p2[i] = ( ( ab1 * p1[i] ) + ( w * abv[i] ) ); } /* Precession and nutation. */ eraRxp( (double(*)[3]) &rms[12], p2, p3 ); /* Geocentric apparent RA,dec. */ eraC2s( p3, ra, da ); *ra = eraAnp( *ra ); }
void eraTrxp(double r[3][3], double p[3], double trp[3]) /* ** - - - - - - - - ** e r a T r x p ** - - - - - - - - ** ** Multiply a p-vector by the transpose of an r-matrix. ** ** Given: ** r double[3][3] r-matrix ** p double[3] p-vector ** ** Returned: ** trp double[3] r * p ** ** Note: ** It is permissible for p and trp to be the same array. ** ** Called: ** eraTr transpose r-matrix ** eraRxp product of r-matrix and p-vector ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double tr[3][3]; /* Transpose of matrix r. */ eraTr(r, tr); /* Matrix tr * vector p -> vector trp. */ eraRxp(tr, p, trp); return; }
void eraH2fk5(double rh, double dh, double drh, double ddh, double pxh, double rvh, double *r5, double *d5, double *dr5, double *dd5, double *px5, double *rv5) /* ** - - - - - - - - - ** e r a H 2 f k 5 ** - - - - - - - - - ** ** Transform Hipparcos star data into the FK5 (J2000.0) system. ** ** Given (all Hipparcos, epoch J2000.0): ** rh double RA (radians) ** dh double Dec (radians) ** drh double proper motion in RA (dRA/dt, rad/Jyear) ** ddh double proper motion in Dec (dDec/dt, rad/Jyear) ** pxh double parallax (arcsec) ** rvh double radial velocity (km/s, positive = receding) ** ** Returned (all FK5, equinox J2000.0, epoch J2000.0): ** r5 double RA (radians) ** d5 double Dec (radians) ** dr5 double proper motion in RA (dRA/dt, rad/Jyear) ** dd5 double proper motion in Dec (dDec/dt, rad/Jyear) ** px5 double parallax (arcsec) ** rv5 double radial velocity (km/s, positive = receding) ** ** Notes: ** ** 1) This function transforms Hipparcos star positions and proper ** motions into FK5 J2000.0. ** ** 2) The proper motions in RA are dRA/dt rather than ** cos(Dec)*dRA/dt, and are per year rather than per century. ** ** 3) The FK5 to Hipparcos transformation is modeled as a pure ** rotation and spin; zonal errors in the FK5 catalog are not ** taken into account. ** ** 4) See also eraFk52h, eraFk5hz, eraHfk5z. ** ** Called: ** eraStarpv star catalog data to space motion pv-vector ** eraFk5hip FK5 to Hipparcos rotation and spin ** eraRv2m r-vector to r-matrix ** eraRxp product of r-matrix and p-vector ** eraTrxp product of transpose of r-matrix and p-vector ** eraPxp vector product of two p-vectors ** eraPmp p-vector minus p-vector ** eraPvstar space motion pv-vector to star catalog data ** ** Reference: ** ** F.Mignard & M.Froeschle, Astron. Astrophys. 354, 732-739 (2000). ** ** Copyright (C) 2013-2015, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { int i; double pvh[2][3], r5h[3][3], s5h[3], sh[3], wxp[3], vv[3], pv5[2][3]; /* Hipparcos barycentric position/velocity pv-vector (normalized). */ eraStarpv(rh, dh, drh, ddh, pxh, rvh, pvh); /* FK5 to Hipparcos orientation matrix and spin vector. */ eraFk5hip(r5h, s5h); /* Make spin units per day instead of per year. */ for ( i = 0; i < 3; s5h[i++] /= 365.25 ); /* Orient the spin into the Hipparcos system. */ eraRxp(r5h, s5h, sh); /* De-orient the Hipparcos position into the FK5 system. */ eraTrxp(r5h, pvh[0], pv5[0]); /* Apply spin to the position giving an extra space motion component. */ eraPxp(pvh[0], sh, wxp); /* Subtract this component from the Hipparcos space motion. */ eraPmp(pvh[1], wxp, vv); /* De-orient the Hipparcos space motion into the FK5 system. */ eraTrxp(r5h, vv, pv5[1]); /* FK5 pv-vector to spherical. */ eraPvstar(pv5, r5, d5, dr5, dd5, px5, rv5); return; }
void eraHfk5z(double rh, double dh, double date1, double date2, double *r5, double *d5, double *dr5, double *dd5) /* ** - - - - - - - - - ** e r a H f k 5 z ** - - - - - - - - - ** ** Transform a Hipparcos star position into FK5 J2000.0, assuming ** zero Hipparcos proper motion. ** ** Given: ** rh double Hipparcos RA (radians) ** dh double Hipparcos Dec (radians) ** date1,date2 double TDB date (Note 1) ** ** Returned (all FK5, equinox J2000.0, date date1+date2): ** r5 double RA (radians) ** d5 double Dec (radians) ** dr5 double FK5 RA proper motion (rad/year, Note 4) ** dd5 double Dec proper motion (rad/year, Note 4) ** ** Notes: ** ** 1) The TT date date1+date2 is a Julian Date, apportioned in any ** convenient way between the two arguments. For example, ** JD(TT)=2450123.7 could be expressed in any of these ways, ** among others: ** ** date1 date2 ** ** 2450123.7 0.0 (JD method) ** 2451545.0 -1421.3 (J2000 method) ** 2400000.5 50123.2 (MJD method) ** 2450123.5 0.2 (date & time method) ** ** The JD method is the most natural and convenient to use in ** cases where the loss of several decimal digits of resolution ** is acceptable. The J2000 method is best matched to the way ** the argument is handled internally and will deliver the ** optimum resolution. The MJD method and the date & time methods ** are both good compromises between resolution and convenience. ** ** 2) The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt. ** ** 3) The FK5 to Hipparcos transformation is modeled as a pure rotation ** and spin; zonal errors in the FK5 catalogue are not taken into ** account. ** ** 4) It was the intention that Hipparcos should be a close ** approximation to an inertial frame, so that distant objects have ** zero proper motion; such objects have (in general) non-zero ** proper motion in FK5, and this function returns those fictitious ** proper motions. ** ** 5) The position returned by this function is in the FK5 J2000.0 ** reference system but at date date1+date2. ** ** 6) See also eraFk52h, eraH2fk5, eraFk5zhz. ** ** Called: ** eraS2c spherical coordinates to unit vector ** eraFk5hip FK5 to Hipparcos rotation and spin ** eraRxp product of r-matrix and p-vector ** eraSxp multiply p-vector by scalar ** eraRxr product of two r-matrices ** eraTrxp product of transpose of r-matrix and p-vector ** eraPxp vector product of two p-vectors ** eraPv2s pv-vector to spherical ** eraAnp normalize angle into range 0 to 2pi ** ** Reference: ** ** F.Mignard & M.Froeschle, 2000, Astron.Astrophys. 354, 732-739. ** ** Copyright (C) 2013, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double t, ph[3], r5h[3][3], s5h[3], sh[3], vst[3], rst[3][3], r5ht[3][3], pv5e[2][3], vv[3], w, r, v; /* Time interval from fundamental epoch J2000.0 to given date (JY). */ t = ((date1 - DJ00) + date2) / DJY; /* Hipparcos barycentric position vector (normalized). */ eraS2c(rh, dh, ph); /* FK5 to Hipparcos orientation matrix and spin vector. */ eraFk5hip(r5h, s5h); /* Rotate the spin into the Hipparcos system. */ eraRxp(r5h, s5h, sh); /* Accumulated Hipparcos wrt FK5 spin over that interval. */ eraSxp(t, s5h, vst); /* Express the accumulated spin as a rotation matrix. */ eraRv2m(vst, rst); /* Rotation matrix: accumulated spin, then FK5 to Hipparcos. */ eraRxr(r5h, rst, r5ht); /* De-orient & de-spin the Hipparcos position into FK5 J2000.0. */ eraTrxp(r5ht, ph, pv5e[0]); /* Apply spin to the position giving a space motion. */ eraPxp(sh, ph, vv); /* De-orient & de-spin the Hipparcos space motion into FK5 J2000.0. */ eraTrxp(r5ht, vv, pv5e[1]); /* FK5 position/velocity pv-vector to spherical. */ eraPv2s(pv5e, &w, d5, &r, dr5, dd5, &v); *r5 = eraAnp(w); return; }
void eraIcrs2g ( double dr, double dd, double *dl, double *db ) /* ** - - - - - - - - - - ** e r a I c r s 2 g ** - - - - - - - - - - ** ** Transformation from ICRS to Galactic Coordinates. ** ** Given: ** dr double ICRS right ascension (radians) ** dd double ICRS declination (radians) ** ** Returned: ** dl double galactic longitude (radians) ** db double galactic latitude (radians) ** ** Notes: ** ** 1) The IAU 1958 system of Galactic coordinates was defined with ** respect to the now obsolete reference system FK4 B1950.0. When ** interpreting the system in a modern context, several factors have ** to be taken into account: ** ** . The inclusion in FK4 positions of the E-terms of aberration. ** ** . The distortion of the FK4 proper motion system by differential ** Galactic rotation. ** ** . The use of the B1950.0 equinox rather than the now-standard ** J2000.0. ** ** . The frame bias between ICRS and the J2000.0 mean place system. ** ** The Hipparcos Catalogue (Perryman & ESA 1997) provides a rotation ** matrix that transforms directly between ICRS and Galactic ** coordinates with the above factors taken into account. The ** matrix is derived from three angles, namely the ICRS coordinates ** of the Galactic pole and the longitude of the ascending node of ** the galactic equator on the ICRS equator. They are given in ** degrees to five decimal places and for canonical purposes are ** regarded as exact. In the Hipparcos Catalogue the matrix ** elements are given to 10 decimal places (about 20 microarcsec). ** In the present ERFA function the matrix elements have been ** recomputed from the canonical three angles and are given to 30 ** decimal places. ** ** 2) The inverse transformation is performed by the function eraG2icrs. ** ** Called: ** eraAnp normalize angle into range 0 to 2pi ** eraAnpm normalize angle into range +/- pi ** eraS2c spherical coordinates to unit vector ** eraRxp product of r-matrix and p-vector ** eraC2s p-vector to spherical ** ** Reference: ** Perryman M.A.C. & ESA, 1997, ESA SP-1200, The Hipparcos and Tycho ** catalogues. Astrometric and photometric star catalogues ** derived from the ESA Hipparcos Space Astrometry Mission. ESA ** Publications Division, Noordwijk, Netherlands. ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double v1[3], v2[3]; /* ** L2,B2 system of galactic coordinates in the form presented in the ** Hipparcos Catalogue. In degrees: ** ** P = 192.85948 right ascension of the Galactic north pole in ICRS ** Q = 27.12825 declination of the Galactic north pole in ICRS ** R = 32.93192 longitude of the ascending node of the Galactic ** plane on the ICRS equator ** ** ICRS to galactic rotation matrix, obtained by computing ** R_3(-R) R_1(pi/2-Q) R_3(pi/2+P) to the full precision shown: */ double r[3][3] = { { -0.054875560416215368492398900454, -0.873437090234885048760383168409, -0.483835015548713226831774175116 }, { +0.494109427875583673525222371358, -0.444829629960011178146614061616, +0.746982244497218890527388004556 }, { -0.867666149019004701181616534570, -0.198076373431201528180486091412, +0.455983776175066922272100478348 } }; /* Spherical to Cartesian. */ eraS2c(dr, dd, v1); /* ICRS to Galactic. */ eraRxp(r, v1, v2); /* Cartesian to spherical. */ eraC2s(v2, dl, db); /* Express in conventional ranges. */ *dl = eraAnp(*dl); *db = eraAnpm(*db); /* Finished. */ }
void eraAtciqz(double rc, double dc, eraASTROM *astrom, double *ri, double *di) /* ** - - - - - - - - - - ** e r a A t c i q z ** - - - - - - - - - - ** ** Quick ICRS to CIRS transformation, given precomputed star- ** independent astrometry parameters, and assuming zero parallax and ** proper motion. ** ** Use of this function is appropriate when efficiency is important and ** where many star positions are to be transformed for one date. The ** star-independent parameters can be obtained by calling one of the ** functions eraApci[13], eraApcg[13], eraApco[13] or eraApcs[13]. ** ** The corresponding function for the case of non-zero parallax and ** proper motion is eraAtciq. ** ** Given: ** rc,dc double ICRS astrometric RA,Dec (radians) ** astrom eraASTROM* star-independent astrometry parameters: ** pmt double PM time interval (SSB, Julian years) ** eb double[3] SSB to observer (vector, au) ** eh double[3] Sun to observer (unit vector) ** em double distance from Sun to observer (au) ** v double[3] barycentric observer velocity (vector, c) ** bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor ** bpn double[3][3] bias-precession-nutation matrix ** along double longitude + s' (radians) ** xpl double polar motion xp wrt local meridian (radians) ** ypl double polar motion yp wrt local meridian (radians) ** sphi double sine of geodetic latitude ** cphi double cosine of geodetic latitude ** diurab double magnitude of diurnal aberration vector ** eral double "local" Earth rotation angle (radians) ** refa double refraction constant A (radians) ** refb double refraction constant B (radians) ** ** Returned: ** ri,di double CIRS RA,Dec (radians) ** ** Note: ** ** All the vectors are with respect to BCRS axes. ** ** References: ** ** Urban, S. & Seidelmann, P. K. (eds), Explanatory Supplement to ** the Astronomical Almanac, 3rd ed., University Science Books ** (2013). ** ** Klioner, Sergei A., "A practical relativistic model for micro- ** arcsecond astrometry in space", Astr. J. 125, 1580-1597 (2003). ** ** Called: ** eraS2c spherical coordinates to unit vector ** eraLdsun light deflection due to Sun ** eraAb stellar aberration ** eraRxp product of r-matrix and p-vector ** eraC2s p-vector to spherical ** eraAnp normalize angle into range +/- pi ** ** Copyright (C) 2013-2015, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double pco[3], pnat[3], ppr[3], pi[3], w; /* BCRS coordinate direction (unit vector). */ eraS2c(rc, dc, pco); /* Light deflection by the Sun, giving BCRS natural direction. */ eraLdsun(pco, astrom->eh, astrom->em, pnat); /* Aberration, giving GCRS proper direction. */ eraAb(pnat, astrom->v, astrom->em, astrom->bm1, ppr); /* Bias-precession-nutation, giving CIRS proper direction. */ eraRxp(astrom->bpn, ppr, pi); /* CIRS RA,Dec. */ eraC2s(pi, &w, di); *ri = eraAnp(w); /* Finished. */ }
void eraFk5hz(double r5, double d5, double date1, double date2, double *rh, double *dh) /* ** - - - - - - - - - ** e r a F k 5 h z ** - - - - - - - - - ** ** Transform an FK5 (J2000.0) star position into the system of the ** Hipparcos catalogue, assuming zero Hipparcos proper motion. ** ** Given: ** r5 double FK5 RA (radians), equinox J2000.0, at date ** d5 double FK5 Dec (radians), equinox J2000.0, at date ** date1,date2 double TDB date (Notes 1,2) ** ** Returned: ** rh double Hipparcos RA (radians) ** dh double Hipparcos Dec (radians) ** ** Notes: ** ** 1) This function converts a star position from the FK5 system to ** the Hipparcos system, in such a way that the Hipparcos proper ** motion is zero. Because such a star has, in general, a non-zero ** proper motion in the FK5 system, the function requires the date ** at which the position in the FK5 system was determined. ** ** 2) The TT date date1+date2 is a Julian Date, apportioned in any ** convenient way between the two arguments. For example, ** JD(TT)=2450123.7 could be expressed in any of these ways, ** among others: ** ** date1 date2 ** ** 2450123.7 0.0 (JD method) ** 2451545.0 -1421.3 (J2000 method) ** 2400000.5 50123.2 (MJD method) ** 2450123.5 0.2 (date & time method) ** ** The JD method is the most natural and convenient to use in ** cases where the loss of several decimal digits of resolution ** is acceptable. The J2000 method is best matched to the way ** the argument is handled internally and will deliver the ** optimum resolution. The MJD method and the date & time methods ** are both good compromises between resolution and convenience. ** ** 3) The FK5 to Hipparcos transformation is modeled as a pure ** rotation and spin; zonal errors in the FK5 catalogue are not ** taken into account. ** ** 4) The position returned by this function is in the Hipparcos ** reference system but at date date1+date2. ** ** 5) See also eraFk52h, eraH2fk5, eraHfk5z. ** ** Called: ** eraS2c spherical coordinates to unit vector ** eraFk5hip FK5 to Hipparcos rotation and spin ** eraSxp multiply p-vector by scalar ** eraRv2m r-vector to r-matrix ** eraTrxp product of transpose of r-matrix and p-vector ** eraPxp vector product of two p-vectors ** eraC2s p-vector to spherical ** eraAnp normalize angle into range 0 to 2pi ** ** Reference: ** ** F.Mignard & M.Froeschle, 2000, Astron.Astrophys. 354, 732-739. ** ** Copyright (C) 2013-2015, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double t, p5e[3], r5h[3][3], s5h[3], vst[3], rst[3][3], p5[3], ph[3], w; /* Interval from given date to fundamental epoch J2000.0 (JY). */ t = - ((date1 - ERFA_DJ00) + date2) / ERFA_DJY; /* FK5 barycentric position vector. */ eraS2c(r5, d5, p5e); /* FK5 to Hipparcos orientation matrix and spin vector. */ eraFk5hip(r5h, s5h); /* Accumulated Hipparcos wrt FK5 spin over that interval. */ eraSxp(t, s5h, vst); /* Express the accumulated spin as a rotation matrix. */ eraRv2m(vst, rst); /* Derotate the vector's FK5 axes back to date. */ eraTrxp(rst, p5e, p5); /* Rotate the vector into the Hipparcos system. */ eraRxp(r5h, p5, ph); /* Hipparcos vector to spherical. */ eraC2s(ph, &w, dh); *rh = eraAnp(w); return; }
void palPertue( double date, double u[13], int *jstat ) { /* Distance from EMB at which Earth and Moon are treated separately */ const double RNE=1.0; /* Coincidence with major planet distance */ const double COINC=0.0001; /* Coefficient relating timestep to perturbing force */ const double TSC=1e-4; /* Minimum and maximum timestep (days) */ const double TSMIN = 0.01; const double TSMAX = 10.0; /* Age limit for major-planet state vector (days) */ const double AGEPMO=5.0; /* Age limit for major-planet mean elements (days) */ const double AGEPEL=50.0; /* Margin for error when deciding whether to renew the planetary data */ const double TINY=1e-6; /* Age limit for the body's osculating elements (before rectification) */ const double AGEBEL=100.0; /* Gaussian gravitational constant squared */ const double GCON2 = PAL__GCON * PAL__GCON; /* The final epoch */ double TFINAL; /* The body's current universal elements */ double UL[13]; /* Current reference epoch */ double T0; /* Timespan from latest orbit rectification to final epoch (days) */ double TSPAN; /* Time left to go before integration is complete */ double TLEFT; /* Time direction flag: +1=forwards, -1=backwards */ double FB; /* First-time flag */ int FIRST = 0; /* * The current perturbations */ /* Epoch (days relative to current reference epoch) */ double RTN; /* Position (AU) */ double PERP[3]; /* Velocity (AU/d) */ double PERV[3]; /* Acceleration (AU/d/d) */ double PERA[3]; /* Length of current timestep (days), and half that */ double TS,HTS; /* Epoch of middle of timestep */ double T; /* Epoch of planetary mean elements */ double TPEL = 0.0; /* Planet number (1=Mercury, 2=Venus, 3=EMB...8=Neptune) */ int NP; /* Planetary universal orbital elements */ double UP[8][13]; /* Epoch of planetary state vectors */ double TPMO = 0.0; /* State vectors for the major planets (AU,AU/s) */ double PVIN[8][6]; /* Earth velocity and position vectors (AU,AU/s) */ double VB[3],PB[3],VH[3],PE[3]; /* Moon geocentric state vector (AU,AU/s) and position part */ double PVM[6],PM[3]; /* Date to J2000 de-precession matrix */ double PMAT[3][3]; /* * Correction terms for extrapolated major planet vectors */ /* Sun-to-planet distances squared multiplied by 3 */ double R2X3[8]; /* Sunward acceleration terms, G/2R^3 */ double GC[8]; /* Tangential-to-circular correction factor */ double FC; /* Radial correction factor due to Sunwards acceleration */ double FG; /* The body's unperturbed and perturbed state vectors (AU,AU/s) */ double PV0[6],PV[6]; /* The body's perturbed and unperturbed heliocentric distances (AU) cubed */ double R03,R3; /* The perturbating accelerations, indirect and direct */ double FI[3],FD[3]; /* Sun-to-planet vector, and distance cubed */ double RHO[3],RHO3; /* Body-to-planet vector, and distance cubed */ double DELTA[3],DELTA3; /* Miscellaneous */ int I,J; double R2,W,DT,DT2,R,FT; int NE; /* Planetary inverse masses, Mercury through Neptune then Earth and Moon */ const double AMAS[10] = { 6023600., 408523.5, 328900.5, 3098710., 1047.355, 3498.5, 22869., 19314., 332946.038, 27068709. }; /* Preset the status to OK. */ *jstat = 0; /* Copy the final epoch. */ TFINAL = date; /* Copy the elements (which will be periodically updated). */ for (I=0; I<13; I++) { UL[I] = u[I]; } /* Initialize the working reference epoch. */ T0=UL[2]; /* Total timespan (days) and hence time left. */ TSPAN = TFINAL-T0; TLEFT = TSPAN; /* Warn if excessive. */ if (fabs(TSPAN) > 36525.0) *jstat=101; /* Time direction: +1 for forwards, -1 for backwards. */ FB = COPYSIGN(1.0,TSPAN); /* Initialize relative epoch for start of current timestep. */ RTN = 0.0; /* Reset the perturbations (position, velocity, acceleration). */ for (I=0; I<3; I++) { PERP[I] = 0.0; PERV[I] = 0.0; PERA[I] = 0.0; } /* Set "first iteration" flag. */ FIRST = 1; /* Step through the time left. */ while (FB*TLEFT > 0.0) { /* Magnitude of current acceleration due to planetary attractions. */ if (FIRST) { TS = TSMIN; } else { R2 = 0.0; for (I=0; I<3; I++) { W = FD[I]; R2 = R2+W*W; } W = sqrt(R2); /* Use the acceleration to decide how big a timestep can be tolerated. */ if (W != 0.0) { TS = DMIN(TSMAX,DMAX(TSMIN,TSC/W)); } else { TS = TSMAX; } } TS = TS*FB; /* Override if final epoch is imminent. */ TLEFT = TSPAN-RTN; if (fabs(TS) > fabs(TLEFT)) TS=TLEFT; /* Epoch of middle of timestep. */ HTS = TS/2.0; T = T0+RTN+HTS; /* Is it time to recompute the major-planet elements? */ if (FIRST || fabs(T-TPEL)-AGEPEL >= TINY) { /* Yes: go forward in time by just under the maximum allowed. */ TPEL = T+FB*AGEPEL; /* Compute the state vector for the new epoch. */ for (NP=1; NP<=8; NP++) { palPlanet(TPEL,NP,PV,&J); /* Warning if remote epoch, abort if error. */ if (J == 1) { *jstat = 102; } else if (J != 0) { goto ABORT; } /* Transform the vector into universal elements. */ palPv2ue(PV,TPEL,0.0,&(UP[NP-1][0]),&J); if (J != 0) goto ABORT; } } /* Is it time to recompute the major-planet motions? */ if (FIRST || fabs(T-TPMO)-AGEPMO >= TINY) { /* Yes: look ahead. */ TPMO = T+FB*AGEPMO; /* Compute the motions of each planet (AU,AU/d). */ for (NP=1; NP<=8; NP++) { /* The planet's position and velocity (AU,AU/s). */ palUe2pv(TPMO,&(UP[NP-1][0]),&(PVIN[NP-1][0]),&J); if (J != 0) goto ABORT; /* Scale velocity to AU/d. */ for (J=3; J<6; J++) { PVIN[NP-1][J] = PVIN[NP-1][J]*PAL__SPD; } /* Precompute also the extrapolation correction terms. */ R2 = 0.0; for (I=0; I<3; I++) { W = PVIN[NP-1][I]; R2 = R2+W*W; } R2X3[NP-1] = R2*3.0; GC[NP-1] = GCON2/(2.0*R2*sqrt(R2)); } } /* Reset the first-time flag. */ FIRST = 0; /* Unperturbed motion of the body at middle of timestep (AU,AU/s). */ palUe2pv(T,UL,PV0,&J); if (J != 0) goto ABORT; /* Perturbed position of the body (AU) and heliocentric distance cubed. */ R2 = 0.0; for (I=0; I<3; I++) { W = PV0[I]+PERP[I]+(PERV[I]+PERA[I]*HTS/2.0)*HTS; PV[I] = W; R2 = R2+W*W; } R3 = R2*sqrt(R2); /* The body's unperturbed heliocentric distance cubed. */ R2 = 0.0; for (I=0; I<3; I++) { W = PV0[I]; R2 = R2+W*W; } R03 = R2*sqrt(R2); /* Compute indirect and initialize direct parts of the perturbation. */ for (I=0; I<3; I++) { FI[I] = PV0[I]/R03-PV[I]/R3; FD[I] = 0.0; } /* Ready to compute the direct planetary effects. */ /* Reset the "near-Earth" flag. */ NE = 0; /* Interval from state-vector epoch to middle of current timestep. */ DT = T-TPMO; DT2 = DT*DT; /* Planet by planet, including separate Earth and Moon. */ for (NP=1; NP<10; NP++) { /* Which perturbing body? */ if (NP <= 8) { /* Planet: compute the extrapolation in longitude (squared). */ R2 = 0.0; for (J=3; J<6; J++) { W = PVIN[NP-1][J]*DT; R2 = R2+W*W; } /* Hence the tangential-to-circular correction factor. */ FC = 1.0+R2/R2X3[NP-1]; /* The radial correction factor due to the inwards acceleration. */ FG = 1.0-GC[NP-1]*DT2; /* Planet's position. */ for (I=0; I<3; I++) { RHO[I] = FG*(PVIN[NP-1][I]+FC*PVIN[NP-1][I+3]*DT); } } else if (NE) { /* Near-Earth and either Earth or Moon. */ if (NP == 9) { /* Earth: position. */ palEpv(T,PE,VH,PB,VB); for (I=0; I<3; I++) { RHO[I] = PE[I]; } } else { /* Moon: position. */ palPrec(palEpj(T),2000.0,PMAT); palDmoon(T,PVM); eraRxp(PMAT,PVM,PM); for (I=0; I<3; I++) { RHO[I] = PM[I]+PE[I]; } } } /* Proceed unless Earth or Moon and not the near-Earth case. */ if (NP <= 8 || NE) { /* Heliocentric distance cubed. */ R2 = 0.0; for (I=0; I<3; I++) { W = RHO[I]; R2 = R2+W*W; } R = sqrt(R2); RHO3 = R2*R; /* Body-to-planet vector, and distance. */ R2 = 0.0; for (I=0; I<3; I++) { W = RHO[I]-PV[I]; DELTA[I] = W; R2 = R2+W*W; } R = sqrt(R2); /* If this is the EMB, set the near-Earth flag appropriately. */ if (NP == 3 && R < RNE) NE = 1; /* Proceed unless EMB and this is the near-Earth case. */ if ( ! (NE && NP == 3) ) { /* If too close, ignore this planet and set a warning. */ if (R < COINC) { *jstat = NP; } else { /* Accumulate "direct" part of perturbation acceleration. */ DELTA3 = R2*R; W = AMAS[NP-1]; for (I=0; I<3; I++) { FD[I] = FD[I]+(DELTA[I]/DELTA3-RHO[I]/RHO3)/W; } } } } } /* Update the perturbations to the end of the timestep. */ RTN += TS; for (I=0; I<3; I++) { W = (FI[I]+FD[I])*GCON2; FT = W*TS; PERP[I] = PERP[I]+(PERV[I]+FT/2.0)*TS; PERV[I] = PERV[I]+FT; PERA[I] = W; } /* Time still to go. */ TLEFT = TSPAN-RTN; /* Is it either time to rectify the orbit or the last time through? */ if (fabs(RTN) >= AGEBEL || FB*TLEFT <= 0.0) { /* Yes: update to the end of the current timestep. */ T0 += RTN; RTN = 0.0; /* The body's unperturbed motion (AU,AU/s). */ palUe2pv(T0,UL,PV0,&J); if (J != 0) goto ABORT; /* Add and re-initialize the perturbations. */ for (I=0; I<3; I++) { J = I+3; PV[I] = PV0[I]+PERP[I]; PV[J] = PV0[J]+PERV[I]/PAL__SPD; PERP[I] = 0.0; PERV[I] = 0.0; PERA[I] = FD[I]*GCON2; } /* Use the position and velocity to set up new universal elements. */ palPv2ue(PV,T0,0.0,UL,&J); if (J != 0) goto ABORT; /* Adjust the timespan and time left. */ TSPAN = TFINAL-T0; TLEFT = TSPAN; } /* Next timestep. */ } /* Return the updated universal-element set. */ for (I=0; I<13; I++) { u[I] = UL[I]; } /* Finished. */ return; /* Miscellaneous numerical error. */ ABORT: *jstat = -1; return; }
void eraEqec06(double date1, double date2, double dr, double dd, double *dl, double *db) /* ** - - - - - - - - - - ** e r a E q e c 0 6 ** - - - - - - - - - - ** ** Transformation from ICRS equatorial coordinates to ecliptic ** coordinates (mean equinox and ecliptic of date) using IAU 2006 ** precession model. ** ** Given: ** date1,date2 double TT as a 2-part Julian date (Note 1) ** dr,dd double ICRS right ascension and declination (radians) ** ** Returned: ** dl,db double ecliptic longitude and latitude (radians) ** ** 1) The TT date date1+date2 is a Julian Date, apportioned in any ** convenient way between the two arguments. For example, ** JD(TT)=2450123.7 could be expressed in any of these ways, ** among others: ** ** date1 date2 ** ** 2450123.7 0.0 (JD method) ** 2451545.0 -1421.3 (J2000 method) ** 2400000.5 50123.2 (MJD method) ** 2450123.5 0.2 (date & time method) ** ** The JD method is the most natural and convenient to use in ** cases where the loss of several decimal digits of resolution ** is acceptable. The J2000 method is best matched to the way ** the argument is handled internally and will deliver the ** optimum resolution. The MJD method and the date & time methods ** are both good compromises between resolution and convenience. ** ** 2) No assumptions are made about whether the coordinates represent ** starlight and embody astrometric effects such as parallax or ** aberration. ** ** 3) The transformation is approximately that from mean J2000.0 right ** ascension and declination to ecliptic longitude and latitude ** (mean equinox and ecliptic of date), with only frame bias (always ** less than 25 mas) to disturb this classical picture. ** ** Called: ** eraS2c spherical coordinates to unit vector ** eraEcm06 J2000.0 to ecliptic rotation matrix, IAU 2006 ** eraRxp product of r-matrix and p-vector ** eraC2s unit vector to spherical coordinates ** eraAnp normalize angle into range 0 to 2pi ** eraAnpm normalize angle into range +/- pi ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double rm[3][3], v1[3], v2[3], a, b; /* Spherical to Cartesian. */ eraS2c(dr, dd, v1); /* Rotation matrix, ICRS equatorial to ecliptic. */ eraEcm06(date1, date2, rm); /* The transformation from ICRS to ecliptic. */ eraRxp(rm, v1, v2); /* Cartesian to spherical. */ eraC2s(v2, &a, &b); /* Express in conventional ranges. */ *dl = eraAnp(a); *db = eraAnpm(b); }
void palDmxv ( double dm[3][3], double va[3], double vb[3] ) { eraRxp( dm, va, vb ); }
void eraLteqec(double epj, double dr, double dd, double *dl, double *db) /* ** - - - - - - - - - - ** e r a L t e q e c ** - - - - - - - - - - ** ** Transformation from ICRS equatorial coordinates to ecliptic ** coordinates (mean equinox and ecliptic of date) using a long-term ** precession model. ** ** Given: ** epj double Julian epoch (TT) ** dr,dd double ICRS right ascension and declination (radians) ** ** Returned: ** dl,db double ecliptic longitude and latitude (radians) ** ** 1) No assumptions are made about whether the coordinates represent ** starlight and embody astrometric effects such as parallax or ** aberration. ** ** 2) The transformation is approximately that from mean J2000.0 right ** ascension and declination to ecliptic longitude and latitude ** (mean equinox and ecliptic of date), with only frame bias (always ** less than 25 mas) to disturb this classical picture. ** ** 3) The Vondrak et al. (2011, 2012) 400 millennia precession model ** agrees with the IAU 2006 precession at J2000.0 and stays within ** 100 microarcseconds during the 20th and 21st centuries. It is ** accurate to a few arcseconds throughout the historical period, ** worsening to a few tenths of a degree at the end of the ** +/- 200,000 year time span. ** ** Called: ** eraS2c spherical coordinates to unit vector ** eraLtecm J2000.0 to ecliptic rotation matrix, long term ** eraRxp product of r-matrix and p-vector ** eraC2s unit vector to spherical coordinates ** eraAnp normalize angle into range 0 to 2pi ** eraAnpm normalize angle into range +/- pi ** ** References: ** ** Vondrak, J., Capitaine, N. and Wallace, P., 2011, New precession ** expressions, valid for long time intervals, Astron.Astrophys. 534, ** A22 ** ** Vondrak, J., Capitaine, N. and Wallace, P., 2012, New precession ** expressions, valid for long time intervals (Corrigendum), ** Astron.Astrophys. 541, C1 ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double rm[3][3], v1[3], v2[3], a, b; /* Spherical to Cartesian. */ eraS2c(dr, dd, v1); /* Rotation matrix, ICRS equatorial to ecliptic. */ eraLtecm(epj, rm); /* The transformation from ICRS to ecliptic. */ eraRxp(rm, v1, v2); /* Cartesian to spherical. */ eraC2s(v2, &a, &b); /* Express in conventional ranges. */ *dl = eraAnp(a); *db = eraAnpm(b); }
void eraAtciq(double rc, double dc, double pr, double pd, double px, double rv, eraASTROM *astrom, double *ri, double *di) /* ** - - - - - - - - - ** e r a A t c i q ** - - - - - - - - - ** ** Quick ICRS, epoch J2000.0, to CIRS transformation, given precomputed ** star-independent astrometry parameters. ** ** Use of this function is appropriate when efficiency is important and ** where many star positions are to be transformed for one date. The ** star-independent parameters can be obtained by calling one of the ** functions eraApci[13], eraApcg[13], eraApco[13] or eraApcs[13]. ** ** If the parallax and proper motions are zero the eraAtciqz function ** can be used instead. ** ** Given: ** rc,dc double ICRS RA,Dec at J2000.0 (radians) ** pr double RA proper motion (radians/year; Note 3) ** pd double Dec proper motion (radians/year) ** px double parallax (arcsec) ** rv double radial velocity (km/s, +ve if receding) ** astrom eraASTROM* star-independent astrometry parameters: ** pmt double PM time interval (SSB, Julian years) ** eb double[3] SSB to observer (vector, au) ** eh double[3] Sun to observer (unit vector) ** em double distance from Sun to observer (au) ** v double[3] barycentric observer velocity (vector, c) ** bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor ** bpn double[3][3] bias-precession-nutation matrix ** along double longitude + s' (radians) ** xpl double polar motion xp wrt local meridian (radians) ** ypl double polar motion yp wrt local meridian (radians) ** sphi double sine of geodetic latitude ** cphi double cosine of geodetic latitude ** diurab double magnitude of diurnal aberration vector ** eral double "local" Earth rotation angle (radians) ** refa double refraction constant A (radians) ** refb double refraction constant B (radians) ** ** Returned: ** ri,di double CIRS RA,Dec (radians) ** ** Notes: ** ** 1) All the vectors are with respect to BCRS axes. ** ** 2) Star data for an epoch other than J2000.0 (for example from the ** Hipparcos catalog, which has an epoch of J1991.25) will require a ** preliminary call to eraPmsafe before use. ** ** 3) The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt. ** ** Called: ** eraPmpx proper motion and parallax ** eraLdsun light deflection by the Sun ** eraAb stellar aberration ** eraRxp product of r-matrix and pv-vector ** eraC2s p-vector to spherical ** eraAnp normalize angle into range 0 to 2pi ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double pco[3], pnat[3], ppr[3], pi[3], w; /* Proper motion and parallax, giving BCRS coordinate direction. */ eraPmpx(rc, dc, pr, pd, px, rv, astrom->pmt, astrom->eb, pco); /* Light deflection by the Sun, giving BCRS natural direction. */ eraLdsun(pco, astrom->eh, astrom->em, pnat); /* Aberration, giving GCRS proper direction. */ eraAb(pnat, astrom->v, astrom->em, astrom->bm1, ppr); /* Bias-precession-nutation, giving CIRS proper direction. */ eraRxp(astrom->bpn, ppr, pi); /* CIRS RA,Dec. */ eraC2s(pi, &w, di); *ri = eraAnp(w); /* Finished. */ }