//------------------------------------------------------------------------- // Assorted private data used for conversions //-------------------------------------------------------------------------
// My own copies of these so compilers are more likely to optimize them away constdouble CalendarAstronomer::PI = 3.14159265358979323846;
//------------------------------------------------------------------------- // Time and date getters and setters //-------------------------------------------------------------------------
//------------------------------------------------------------------------- // Coordinate transformations, all based on the current time of this object //-------------------------------------------------------------------------
/** *Convertfromecliptictoequatorialcoordinates. * *@parameclipLongTheeclipticlongitude *@parameclipLatTheeclipticlatitude * *@returnThecorrespondingpointinequatorialcoordinates. *@internal *@deprecatedICU2.4.Thisclassmayberemovedormodified.
*/
CalendarAstronomer::Equatorial& CalendarAstronomer::eclipticToEquatorial(CalendarAstronomer::Equatorial& result, double eclipLong, double eclipLat)
{ // See page 42 of "Practical Astronomy with your Calculator", // by Peter Duffet-Smith, for details on the algorithm.
//------------------------------------------------------------------------- // The Sun //-------------------------------------------------------------------------
// // Parameters of the Sun's orbit as of the epoch Jan 0.0 1990 // Angles are in radians (after multiplying by CalendarAstronomer::PI/180) // #define JD_EPOCH 2447891.5// Julian day of epoch
#define SUN_ETA_G (279.403303 * CalendarAstronomer::PI/180) // Ecliptic longitude at epoch #define SUN_OMEGA_G (282.768422 * CalendarAstronomer::PI/180) // Ecliptic longitude of perigee #define SUN_E 0.016713// Eccentricity of orbit //double sunR0 1.495585e8 // Semi-major axis in KM //double sunTheta0 (0.533128 * CalendarAstronomer::PI/180) // Angular diameter at R0
// The following three methods, which compute the sun parameters // given above for an arbitrary epoch (whatever time the object is // set to), make only a small difference as compared to using the // above constants. E.g., Sunset times might differ by ~12 // seconds. Furthermore, the eta-g computation is befuddled by // Duffet-Smith's incorrect coefficients (p.86). I've corrected // the first-order coefficient but the others may be off too - no // way of knowing without consulting another source.
// /** // * Return the sun's ecliptic longitude at perigee for the current time. // * See Duffett-Smith, p. 86. // * @return radians // */ // private double getSunOmegaG() { // double T = getJulianCentury(); // return (281.2208444 + (1.719175 + 0.000452778*T)*T) * DEG_RAD; // }
// /** // * Return the sun's ecliptic longitude for the current time. // * See Duffett-Smith, p. 86. // * @return radians // */ // private double getSunEtaG() { // double T = getJulianCentury(); // //return (279.6966778 + (36000.76892 + 0.0003025*T)*T) * DEG_RAD; // // // // The above line is from Duffett-Smith, and yields manifestly wrong // // results. The below constant is derived empirically to match the // // constant he gives for the 1990 EPOCH. // // // return (279.6966778 + (-0.3262541582718024 + 0.0003025*T)*T) * DEG_RAD; // }
// /** // * Return the sun's eccentricity of orbit for the current time. // * See Duffett-Smith, p. 86. // * @return double // */ // private double getSunE() { // double T = getJulianCentury(); // return 0.01675104 - (0.0000418 + 0.000000126*T)*T; // }
/** *Findthe"trueanomaly"(longitude)ofanobjectfrom *itsmeananomalyandtheeccentricityofitsorbit.Thisuses *aniterativesolutiontoKepler'sequation. * *@parammeanAnomalyTheobject'slongitudecalculatedasifitwerein *aregular,circularorbit,measuredinradians *fromthepointofperigee. * *@parameccentricityTheeccentricityoftheorbit * *@returnThetrueanomaly(longitude)measuredinradians
*/ staticdouble trueAnomaly(double meanAnomaly, double eccentricity)
{ // First, solve Kepler's equation iteratively // Duffett-Smith, p.90 double delta; double E = meanAnomaly; do {
delta = E - eccentricity * ::sin(E) - meanAnomaly;
E = E - delta / (1 - eccentricity * ::cos(E));
} while (uprv_fabs(delta) > 1e-5); // epsilon = 1e-5 rad
/** *Thelongitudeofthesunatthetimespecifiedbythisobject. *Thelongitudeismeasuredinradiansalongtheecliptic *fromthe"firstpointofAries,"thepointatwhichtheecliptic *crossestheearth'sequatorialplaneatthevernalequinox. *<p> *Currently,thismethodusesanapproximationofthetwo-bodyKepler's *equationfortheearthandthesun.Itdoesnottakeintoaccountthe *perturbationscausedbytheotherplanets,themoon,etc. *@internal *@deprecatedICU2.4.Thisclassmayberemovedormodified.
*/ double CalendarAstronomer::getSunLongitude()
{ // See page 86 of "Practical Astronomy with your Calculator", // by Peter Duffet-Smith, for details on the algorithm.
if (isINVALID(sunLongitude)) {
getSunLongitude(getJulianDay(), sunLongitude, meanAnomalySun);
} return sunLongitude;
}
/** *TODOMakethispublicwhentheentireclassispackage-private.
*/ /*public*/ void CalendarAstronomer::getSunLongitude(double jDay, double &longitude, double &meanAnomaly)pan>
{ // See page 86 of "Practical Astronomy with your Calculator", // by Peter Duffet-Smith, for details on the algorithm.
double day = jDay - JD_EPOCH; // Days since epoch
// Find the angular distance the sun in a fictitious // circular orbit has travelled since the epoch. double epochAngle = norm2PI(CalendarAstronomer_PI2/TROPICAL_YEAR*day);
// The epoch wasn't at the sun's perigee; find the angular distance // since perigee, which is called the "mean anomaly"
meanAnomaly = norm2PI(epochAngle + SUN_ETA_G - SUN_OMEGA_G);
// Now find the "true anomaly", e.g. the real solar longitude // by solving Kepler's equation for an elliptical orbit // NOTE: The 3rd ed. of the book lists omega_g and eta_g in different // equations; omega_g is to be correct.
longitude = norm2PI(trueAnomaly(meanAnomaly, SUN_E) + SUN_OMEGA_G);
}
//------------------------------------------------------------------------- // The Moon //-------------------------------------------------------------------------
#define moonL0 (318.351648 * CalendarAstronomer::PI/180 ) // Mean long. at epoch #define moonP0 ( 36.340410 * CalendarAstronomer::PI/180 ) // Mean long. of perigee #define moonN0 ( 318.510107 * CalendarAstronomer::PI/180 ) // Mean long. of node #define moonI ( 5.145366 * CalendarAstronomer::PI/180 ) // Inclination of orbit #define moonE ( 0.054900 ) // Eccentricity of orbit
// These aren't used right now #define moonA ( 3.84401e5 ) // semi-major axis (km) #define moonT0 ( 0.5181 * CalendarAstronomer::PI/180 ) // Angular size at distance A #define moonPi ( 0.9507 * CalendarAstronomer::PI/180 ) // Parallax at distance A
/** *Thepositionofthemoonatthetimesetonthis *object,inequatorialcoordinates. *@internal *@deprecatedICU2.4.Thisclassmayberemovedormodified.
*/ const CalendarAstronomer::Equatorial& CalendarAstronomer::getMoonPosition()
{ // // See page 142 of "Practical Astronomy with your Calculator", // by Peter Duffet-Smith, for details on the algorithm. // if (moonPositionSet == false) { // Calculate the solar longitude. Has the side effect of // filling in "meanAnomalySun" as well.
getSunLongitude();
// // Find the # of days since the epoch of our orbital parameters. // TODO: Convert the time of day portion into ephemeris time // double day = getJulianDay() - JD_EPOCH; // Days since epoch
// Calculate the mean longitude and anomaly of the moon, based on // a circular orbit. Similar to the corresponding solar calculation. double meanLongitude = norm2PI(13.1763966*PI/180*day + moonL0); double meanAnomalyMoon = norm2PI(meanLongitude - 0.1114041*PI/180 * day - moonP0);
// // Calculate the following corrections: // Evection: the sun's gravity affects the moon's eccentricity // Annual Eqn: variation in the effect due to earth-sun distance // A3: correction factor (for ???) // double evection = 1.2739*PI/180 * ::sin(2 * (meanLongitude - sunLongitude)
- meanAnomalyMoon); double annual = 0.1858*PI/180 * ::sin(meanAnomalySun); double a3 = 0.3700*PI/180 * ::sin(meanAnomalySun);
meanAnomalyMoon += evection - annual - a3;
// // More correction factors: // center equation of the center correction // a4 yet another error correction (???) // // TODO: Skip the equation of the center correction and solve Kepler's eqn? // double center = 6.2886*PI/180 * ::sin(meanAnomalyMoon); double a4 = 0.2140*PI/180 * ::sin(2 * meanAnomalyMoon);
// Now find the moon's corrected longitude double moonLongitude = meanLongitude + evection + center - annual + a4;
// // And finally, find the variation, caused by the fact that the sun's // gravitational pull on the moon varies depending on which side of // the earth the moon is on // double variation = 0.6583*CalendarAstronomer::PI/180 * ::sin(2*(moonLongitude - sunLongitude));
moonLongitude += variation;
// // What we've calculated so far is the moon's longitude in the plane // of its own orbit. Now map to the ecliptic to get the latitude // and longitude. First we need to find the longitude of the ascending // node, the position on the ecliptic where it is crossed by the moon's // orbit as it crosses from the southern to the northern hemisphere. // double nodeLongitude = norm2PI(moonN0 - 0.0529539*PI/180 * day);
/** *The"age"ofthemoonatthetimespecifiedinthisobject. *Thisisreallytheanglebetweenthe *currenteclipticlongitudesofthesunandthemoon, *measuredinradians. * *@internal *@deprecatedICU2.4.Thisclassmayberemovedormodified.
*/ double CalendarAstronomer::getMoonAge() { // See page 147 of "Practical Astronomy with your Calculator", // by Peter Duffet-Smith, for details on the algorithm. // // Force the moon's position to be calculated. We're going to use // some the intermediate results cached during that calculation. //
getMoonPosition();
//------------------------------------------------------------------------- // Interpolation methods for finding the time at which a given event occurs //-------------------------------------------------------------------------
UDate CalendarAstronomer::timeOfAngle(AngleFunc& func, double desired, double periodDays, double epsilon, UBool next)
{ // Find the value of the function at the current time double lastAngle = func.eval(*this);
// Find out how far we are from the desired angle double deltaAngle = norm2PI(desired - lastAngle) ;
// Using the average period, estimate the next (or previous) time at // which the desired angle occurs. double deltaT = (deltaAngle + (next ? 0.0 : - CalendarAstronomer_PI2 )) * (periodDays*DAY_MS) / CalendarAstronomer_PI2;
double lastDeltaT = deltaT; // Liu
UDate startTime = fTime; // Liu
setTime(fTime + uprv_ceil(deltaT));
// Now iterate until we get the error below epsilon. Throughout // this loop we use normPI to get values in the range -Pi to Pi, // since we're using them as correction factors rather than absolute angles. do { // Evaluate the function at the time we've estimated double angle = func.eval(*this);
// Find the # of milliseconds per radian at this point on the curve double factor = uprv_fabs(deltaT / normPI(angle-lastAngle));
// Correct the time estimate based on how far off the angle is
deltaT = normPI(desired - angle) * factor;
// HACK: // // If abs(deltaT) begins to diverge we need to quit this loop. // This only appears to happen when attempting to locate, for // example, a new moon on the day of the new moon. E.g.: // // This result is correct: // newMoon(7508(Mon Jul 23 00:00:00 CST 1990,false))= // Sun Jul 22 10:57:41 CST 1990 // // But attempting to make the same call a day earlier causes deltaT // to diverge: // CalendarAstronomer.timeOfAngle() diverging: 1.348508727575625E9 -> // 1.3649828540224032E9 // newMoon(7507(Sun Jul 22 00:00:00 CST 1990,false))= // Sun Jul 08 13:56:15 CST 1990 // // As a temporary solution, we catch this specific condition and // adjust our start time by one eighth period days (either forward // or backward) and try again. // Liu 11/9/00 if (uprv_fabs(deltaT) > uprv_fabs(lastDeltaT)) { double delta = uprv_ceil (periodDays * DAY_MS / 8.0);
setTime(startTime + (next ? delta : -delta)); return timeOfAngle(func, desired, periodDays, epsilon, next);
}
lastDeltaT = deltaT;
lastAngle = angle;
setTime(fTime + uprv_ceil(deltaT));
} while (uprv_fabs(deltaT) > epsilon);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.