StelUtils.cpp   StelUtils.cpp 
skipping to change at line 72 skipping to change at line 72
QString platform = StelUtils::getOperatingSystemInfo(); QString platform = StelUtils::getOperatingSystemInfo();
if (platform.contains("Linux")) if (platform.contains("Linux"))
platform = "Linux"; platform = "Linux";
if (platform.contains("FreeBSD")) if (platform.contains("FreeBSD"))
platform = "FreeBSD"; platform = "FreeBSD";
if (platform.contains("NetBSD")) if (platform.contains("NetBSD"))
platform = "NetBSD"; platform = "NetBSD";
if (platform.contains("OpenBSD")) if (platform.contains("OpenBSD"))
platform = "OpenBSD"; platform = "OpenBSD";
// Set user agent as "Stellarium/$version$ ($platform$)" // Set user agent as "Stellarium/$version$ ($platform$; $CPU archite
cture$)"
#if QT_VERSION >= 0x050400
// TODO: Remove #ifdef when Qt 5.4 will set as minimal
platform.append("; " + QSysInfo::currentCpuArchitecture());
#endif
return QString("Stellarium/%1 (%2)").arg(StelUtils::getApplicationVe rsion()).arg(platform); return QString("Stellarium/%1 (%2)").arg(StelUtils::getApplicationVe rsion()).arg(platform);
} }
QString getOperatingSystemInfo() QString getOperatingSystemInfo()
{ {
QString OS = "Unknown operating system"; QString OS = "Unknown operating system";
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
switch(QSysInfo::WindowsVersion) switch(QSysInfo::WindowsVersion)
{ {
skipping to change at line 161 skipping to change at line 166
OS = "Mac OS X 10.9 series"; OS = "Mac OS X 10.9 series";
break; break;
case QSysInfo::MV_YOSEMITE: case QSysInfo::MV_YOSEMITE:
OS = "Mac OS X 10.10 series"; OS = "Mac OS X 10.10 series";
break; break;
#if QT_VERSION >= 0x050500 #if QT_VERSION >= 0x050500
case QSysInfo::MV_ELCAPITAN: case QSysInfo::MV_ELCAPITAN:
OS = "Mac OS X 10.11 series"; OS = "Mac OS X 10.11 series";
break; break;
#endif #endif
#if QT_VERSION >= 0x050600
case QSysInfo::MV_SIERRA:
OS = "Mac OS X 10.12 series";
break;
#endif
default: default:
OS = "Unsupported Mac version"; OS = "Unsupported Mac version";
break; break;
} }
#elif defined Q_OS_LINUX #elif defined Q_OS_LINUX
QFile procVersion("/proc/version"); QFile procVersion("/proc/version");
if(!procVersion.open(QIODevice::ReadOnly | QIODevice::Text)) if(!procVersion.open(QIODevice::ReadOnly | QIODevice::Text))
OS = "Unknown Linux version"; OS = "Unknown Linux version";
else else
skipping to change at line 684 skipping to change at line 694
{ {
double returned; double returned;
if(z>0) if(z>0)
returned = std::log(z + std::sqrt(z*z+1)); returned = std::log(z + std::sqrt(z*z+1));
else else
returned = -std::log(-z + std::sqrt(z*z+1)); returned = -std::log(-z + std::sqrt(z*z+1));
return returned; return returned;
} }
// Simple integer modulo where the result is always positive.
int imod(const int a, const int b)
{
int ret = a % b;
if(ret < 0)
ret+=b;
return ret;
}
/************************************************************************* /*************************************************************************
Convert a QT QDateTime class to julian day Convert a QT QDateTime class to julian day
*************************************************************************/ *************************************************************************/
double qDateTimeToJd(const QDateTime& dateTime) double qDateTimeToJd(const QDateTime& dateTime)
{ {
return (double)(dateTime.date().toJulianDay())+(double)1./(24*60*60* 1000)*QTime(0, 0, 0, 0).msecsTo(dateTime.time())-0.5; return (double)(dateTime.date().toJulianDay())+(double)1./(24*60*60* 1000)*QTime(0, 0, 0, 0).msecsTo(dateTime.time())-0.5;
} }
QDateTime jdToQDateTime(const double& jd) QDateTime jdToQDateTime(const double& jd)
{ {
skipping to change at line 1110 skipping to change at line 1129
case 13: case 13:
return numberOfDaysInMonthInYear(1, year+1); return numberOfDaysInMonthInYear(1, year+1);
break; break;
default: default:
break; break;
} }
return 0; return 0;
} }
// return true if year is a leap year. Observes 1582 switch from Julian to
Gregorian Calendar.
bool isLeapYear(const int year)
{
if (year>1582){
if (year % 400 == 0)
return true;
else if (year % 100 == 0)
return false;
else return (year % 4 == 0);
}
else
return (year % 4 == 0);
}
// Find day number for date in year.
// Meeus, AA 2nd, 1998, ch.7 p.65
int dayInYear(const int year, const int month, const int day)
{
// set k to 1 (leap) or 2.
int k=(isLeapYear(year) ? 1:2);
return (int)(275*month/9) - k*(int)((month+9)/12) + day -30;
}
// Return a fractional year like YYYY.ddddd. For negative years, the year n
umber is of course decrease. E.g. -500.5 occurs in -501.
double yearFraction(const int year, const int month, const double day)
{
double d=dayInYear(year, month, 0)+day;
double daysInYear=( isLeapYear(year) ? 366.0 : 365.0);
return year+d/daysInYear;
}
//! given the submitted year/month/day hour:minute:second, try to //! given the submitted year/month/day hour:minute:second, try to
//! normalize into an actual year/month/day. values can be positive, 0, //! normalize into an actual year/month/day. values can be positive, 0,
//! or negative. start assessing from seconds to larger increments. //! or negative. start assessing from seconds to larger increments.
bool changeDateTimeForRollover(int oy, int om, int od, int oh, int omin, in t os, bool changeDateTimeForRollover(int oy, int om, int od, int oh, int omin, in t os,
int* ry, int* rm, int* rd, int* rh, int* rmin , int* rs) int* ry, int* rm, int* rd, int* rh, int* rmin , int* rs)
{ {
bool change = false; bool change = false;
while ( os > 59 ) { while ( os > 59 ) {
os -= 60; os -= 60;
skipping to change at line 1296 skipping to change at line 1347
/* /////////////////// DELTA T VARIANTS /* /////////////////// DELTA T VARIANTS
// For the standard epochs for many formulae, we use // For the standard epochs for many formulae, we use
// J2000.0=2000-jan-1.5=2451545.0, // J2000.0=2000-jan-1.5=2451545.0,
// 1900.0=1900-jan-0.5=2415020.0 // 1900.0=1900-jan-0.5=2415020.0
// 1820.0=1820-jan-0.5=2385800.0 // 1820.0=1820-jan-0.5=2385800.0
// 1810.0=1810-jan-0.5=2382148.0 // 1810.0=1810-jan-0.5=2382148.0
// 1800.0=1800-jan-0.5=2378496.0 // 1800.0=1800-jan-0.5=2378496.0
// 1735.0=1735-jan-0.5=2354755.0 // 1735.0=1735-jan-0.5=2354755.0
// 1625.0=1625-jan-0.5=2314579.0 // 1625.0=1625-jan-0.5=2314579.0
//
// Up to V0.15.1, if the requested year was outside validity range, we retu
rned zero or some useless value.
// Starting with V0.15.2 the value from the edge of the range is returned i
nstead.
*/ */
double getDeltaTwithoutCorrection(const double jDay)
{
Q_UNUSED(jDay)
return 0.;
}
// Implementation of algorithm by Espenak & Meeus (2006) for DeltaT computa tion // Implementation of algorithm by Espenak & Meeus (2006) for DeltaT computa tion
double getDeltaTByEspenakMeeus(const double jDay) double getDeltaTByEspenakMeeus(const double jDay)
{ {
int year, month, day; int year, month, day;
getDateFromJulianDay(jDay, &year, &month, &day); getDateFromJulianDay(jDay, &year, &month, &day);
// Note: the method here is adapted from // Note: the method here is adapted from
// "Five Millennium Canon of Solar Eclipses" [Espenak and Meeus, 200 6] // "Five Millennium Canon of Solar Eclipses" [Espenak and Meeus, 200 6]
// A summary is described here: // A summary is described here:
// http://eclipse.gsfc.nasa.gov/SEhelp/deltatpoly2004.html // http://eclipse.gsfc.nasa.gov/SEhelp/deltatpoly2004.html
skipping to change at line 1465 skipping to change at line 1525
return (38.30*u +114.0)*u +20.0; return (38.30*u +114.0)*u +20.0;
} }
// Implementation of algorithm by Stephenson (1997) for DeltaT computation // Implementation of algorithm by Stephenson (1997) for DeltaT computation
double getDeltaTByStephenson1997(const double jDay) double getDeltaTByStephenson1997(const double jDay)
{ {
double u=(jDay-2354755.0)/36525.0; // (1735-jan-0.5) double u=(jDay-2354755.0)/36525.0; // (1735-jan-0.5)
return -20.0 + 35.0*u*u; return -20.0 + 35.0*u*u;
} }
// Implementation of algorithm by Schmadel & Zech (1979) for DeltaT computa tion // Implementation of algorithm by Schmadel & Zech (1979) for DeltaT computa tion. STRICTLY 1800...1975 ONLY!! Now delivers values for the edges.
double getDeltaTBySchmadelZech1979(const double jDay) double getDeltaTBySchmadelZech1979(const double jDay)
{ {
double u=(jDay-2415020.0)/36525.0; // (1900-jan-0.5) double u=(jDay-2415020.0)/36525.0; // (1900-jan-0.5)
u=qMax(-1.0, qMin(u, 0.76)); // Limit range to 1800...1975. Else we have crazy values which cause strange artefacts.
double deltaT=(((((((((((-0.089491*u -0.117389)*u + 0.185489)*u + 0. 247433)*u - 0.159732)*u - 0.200097)*u + 0.075456)*u double deltaT=(((((((((((-0.089491*u -0.117389)*u + 0.185489)*u + 0. 247433)*u - 0.159732)*u - 0.200097)*u + 0.075456)*u
+ 0.076929)*u - 0.020446)*u - 0.013867)*u + 0.003081 )*u + 0.001233)*u -0.000029; + 0.076929)*u - 0.020446)*u - 0.013867)*u + 0.003081 )*u + 0.001233)*u -0.000029;
return deltaT * 86400.0; return deltaT * 86400.0;
} }
// Implementation of algorithm by Morrison & Stephenson (1982) for DeltaT c omputation // Implementation of algorithm by Morrison & Stephenson (1982) for DeltaT c omputation
double getDeltaTByMorrisonStephenson1982(const double jDay) double getDeltaTByMorrisonStephenson1982(const double jDay)
{ {
double u=(jDay-2382148.0)/36525.0; // (1810-jan-0.5) double u=(jDay-2382148.0)/36525.0; // (1810-jan-0.5)
return -15.0+32.50*u*u; return -15.0+32.50*u*u;
} }
// Implementation of algorithm by Stephenson & Morrison (1984) for DeltaT c omputation // Implementation of algorithm by Stephenson & Morrison (1984) for DeltaT c omputation
double getDeltaTByStephensonMorrison1984(const double jDay) double getDeltaTByStephensonMorrison1984(const double jDay)
{ {
int year, month, day; int year, month, day;
double deltaT = 0.; double deltaT = 0.;
getDateFromJulianDay(jDay, &year, &month, &day); getDateFromJulianDay(jDay, &year, &month, &day);
// Limited years!
year=qMax(-391, qMin(year, 1600));
double u = (getDecYear(year, month, day)-1800)/100; double u = (getDecYear(year, month, day)-1800)/100;
if (-391 < year && year <= 948) if (-391 < year && year <= 948)
deltaT = (44.3*u +320.0)*u +1360.0; deltaT = (44.3*u +320.0)*u +1360.0;
if (948 < year && year <= 1600) if (948 < year && year <= 1600)
deltaT = 25.5*u*u; deltaT = 25.5*u*u;
return deltaT; return deltaT;
} }
// Implementation of algorithm by Stephenson & Morrison (1995) for DeltaT c omputation // Implementation of algorithm by Stephenson & Morrison (1995) for DeltaT c omputation
double getDeltaTByStephensonMorrison1995(const double jDay) double getDeltaTByStephensonMorrison1995(const double jDay)
{ {
double u=(jDay-2385800.0)/36525.0; // (1820-jan-0.5) double u=(jDay-2385800.0)/36525.0; // (1820-jan-0.5)
return -20.0 + 31.0*u*u; return -20.0 + 31.0*u*u;
} }
// Implementation of algorithm by Stephenson & Houlden (1986) for DeltaT co mputation // Implementation of algorithm by Stephenson & Houlden (1986) for DeltaT co mputation
double getDeltaTByStephensonHoulden(const double jDay) double getDeltaTByStephensonHoulden(const double jDay)
{ {
int year, month, day; // TODO FIXME: GZ 2016-12: WHAT IS THIS?? Stephenson-Houlden 1986 ha
double u; s a different Formula!!
double deltaT = 0.; // int year, month, day;
getDateFromJulianDay(jDay, &year, &month, &day); // double u;
// double deltaT = 0.;
double yeardec=getDecYear(year, month, day); // getDateFromJulianDay(jDay, &year, &month, &day);
if (year <= 948) // double yeardec=getDecYear(year, month, day);
{ // // Limited years!?
u = (yeardec-948)/100; // year=qMax(-600, qMin(year, 1600));
deltaT = (46.5*u -405.0)*u + 1830.0;
} // if (year <= 948)
if (948 < year && year <= 1600) // {
{ // u = (yeardec-948)/100;
u = (yeardec-1850)/100; // deltaT = (46.5*u -405.0)*u + 1830.0;
deltaT = 22.5*u*u; // }
} // if (948 < year && year <= 1600)
// {
// u = (yeardec-1850)/100;
// deltaT = 22.5*u*u;
// }
// return deltaT;
// This formula found in the cited book, page (ii), formula (1).
double T=(jDay-2415020.0)/36525; // centuries from J1900.0
return deltaT; return (36.79*T+35.06)*T+4.87;
} }
// Implementation of algorithm by Espenak (1987, 1989) for DeltaT computati on // Implementation of algorithm by Espenak (1987, 1989) for DeltaT computati on
double getDeltaTByEspenak(const double jDay) double getDeltaTByEspenak(const double jDay)
{ {
double u=(jDay-2451545.0)/36525.0; // (2000-jan-1.5) double u=(jDay-2451545.0)/36525.0; // (2000-jan-1.5)
return (64.3*u +61.0)*u +67.0; return (64.3*u +61.0)*u +67.0;
} }
// Implementation of algorithm by Borkowski (1988) for DeltaT computation // Implementation of algorithm by Borkowski (1988) for DeltaT computation
// This is explicitly compatible with ELP2000-85. // This is explicitly compatible with ELP2000-85.
double getDeltaTByBorkowski(const double jDay) double getDeltaTByBorkowski(const double jDay)
{ {
double u=(jDay-2451545.0)/36525.0 + 3.75; // (2000-jan-1.5), deviati on from 1625 as given in the paper. double u=(jDay-2451545.0)/36525.0 + 3.75; // (2000-jan-1.5), deviati on from 1625 as given in the paper.
return 40.0 + 35.0*u*u; return 40.0 + 35.0*u*u;
} }
// Implementation of algorithm by Schmadel & Zech (1988) for DeltaT computa tion // Implementation of algorithm by Schmadel & Zech (1988) for DeltaT computa tion. STRICTLY 1800...1988 ONLY!! Now delivers values for the edges.
double getDeltaTBySchmadelZech1988(const double jDay) double getDeltaTBySchmadelZech1988(const double jDay)
{ {
double u=(jDay-2415020.0)/36525.0; // (1900-jan-0.5) double u=(jDay-2415020.0)/36525.0; // (1900-jan-0.5)
u=qMax(-1.0, qMin(u, 0.89)); // Limit range to 1800...1988. Else we have crazy values which cause strange artefacts.
double deltaT = (((((((((((-0.058091*u -0.067471)*u +.145932)*u +.16 1416)*u -.149279)*u -.146960)*u +.079441)*u +.062971)*u -.022542)*u -.01246 2)*u +.003357)*u +.001148)*u-.000014; double deltaT = (((((((((((-0.058091*u -0.067471)*u +.145932)*u +.16 1416)*u -.149279)*u -.146960)*u +.079441)*u +.062971)*u -.022542)*u -.01246 2)*u +.003357)*u +.001148)*u-.000014;
return deltaT * 86400.0; return deltaT * 86400.0;
} }
// Implementation of algorithm by Chapront-Touzé & Chapront (1991) for Delt aT computation // Implementation of algorithm by Chapront-Touzé & Chapront (1991) for Delt aT computation
double getDeltaTByChaprontTouze(const double jDay) double getDeltaTByChaprontTouze(const double jDay)
{ {
int year, month, day; int year, month, day;
double deltaT = 0.; double deltaT = 0.;
getDateFromJulianDay(jDay, &year, &month, &day); getDateFromJulianDay(jDay, &year, &month, &day);
// Limited years!
year=qMax(-391, qMin(year, 1600));
double u=(jDay-2451545.0)/36525.0; // (2000-jan-1.5) double u=(jDay-2451545.0)/36525.0; // (2000-jan-1.5)
if (-391 < year && year <= 948) if (-391 < year && year <= 948)
deltaT = (42.4*u +495.0)*u + 2177.0; deltaT = (42.4*u +495.0)*u + 2177.0;
if (948 < year && year <= 1600) if (948 < year && year <= 1600)
deltaT = (23.6*u +100.0)*u + 102.0; deltaT = (23.6*u +100.0)*u + 102.0;
return deltaT; return deltaT;
} }
// Implementation of algorithm by JPL Horizons for DeltaT computation // Implementation of algorithm by JPL Horizons for DeltaT computation
double getDeltaTByJPLHorizons(const double jDay) double getDeltaTByJPLHorizons(const double jDay)
{ // FIXME: It does not make sense to have zeros after 1620 in a JPL Horizo ns compatible implementation! { // FIXME: It does not make sense to have zeros after 1620 in a JPL Horizo ns compatible implementation!
int year, month, day; int year, month, day;
double u; double u;
double deltaT = 0.; double deltaT = 0.;
getDateFromJulianDay(jDay, &year, &month, &day); getDateFromJulianDay(jDay, &year, &month, &day);
// Limited years!
year=qMax(-2999, qMin(year, 1620));
if (-2999 < year && year < 948) if (-2999 < year && year < 948)
{ {
u=(jDay-2385800.0)/36525.0; // (1820-jan-1.5) u=(jDay-2385800.0)/36525.0; // (1820-jan-1.5)
deltaT = 31.0*u*u; deltaT = 31.0*u*u;
} }
if (948 < year && year <= 1620) if (948 < year && year <= 1620)
{ {
u=(jDay-2451545.0)/36525.0; // (2000-jan-1.5) u=(jDay-2451545.0)/36525.0; // (2000-jan-1.5)
deltaT = (22.5*u +67.5)*u + 50.6; deltaT = (22.5*u +67.5)*u + 50.6;
} }
skipping to change at line 1705 skipping to change at line 1782
//double yeardec=year+((month-1)*30.5+day/31*30.5)/366; //double yeardec=year+((month-1)*30.5+day/31*30.5)/366;
//double ub = (yeardec-2000)/100; //double ub = (yeardec-2000)/100;
const double ub=(jDay-2451545.0)/36525.0; // (2000-jan-1.5) const double ub=(jDay-2451545.0)/36525.0; // (2000-jan-1.5)
if (year <1620) if (year <1620)
deltaT=0.0; deltaT=0.0;
else if (year < 1690) else if (year < 1690)
{ {
u = 3.45 + ub; u = 3.45 + ub;
//deltaT = +40.3 - 107.0*u + 50.0*std::pow(u,2) - 454.0*std: :pow(u,3) + 1244.0*std::pow(u,4);
deltaT = (((1244.0*u -454.0)*u + 50.0)*u -107.0)*u +40.3; deltaT = (((1244.0*u -454.0)*u + 50.0)*u -107.0)*u +40.3;
} }
else if (year < 1770) else if (year < 1770)
{ {
u = 2.70 + ub; u = 2.70 + ub;
//deltaT = +10.2 + 11.3*u - std::pow(u,2) - 16.0*std::pow(u, 3) + 70.0*std::pow(u,4);
deltaT = (((70.0*u -16.0)*u -1.0)*u +11.3)*u +10.2; deltaT = (((70.0*u -16.0)*u -1.0)*u +11.3)*u +10.2;
} }
else if (year < 1820) else if (year < 1820)
{ {
u = 2.05 + ub; u = 2.05 + ub;
//deltaT = +14.7 - 18.8*u - 22.0*std::pow(u,2) + 173.0*std:: pow(u,3) + 6.0*std::pow(u,4);
deltaT = (((6.0*u +173.0)*u -22.0)*u -18.8)*u +14.7; deltaT = (((6.0*u +173.0)*u -22.0)*u -18.8)*u +14.7;
} }
else if (year < 1870) else if (year < 1870)
{ {
u = 1.55 + ub; u = 1.55 + ub;
//deltaT = +5.7 + 12.7*u + 111.0*std::pow(u,2) - 534.0*std:: pow(u,3) - 1654.0*std::pow(u,4);
deltaT = (((-1654.0*u -534.0)*u +111)*u +12.7)*u +5.7; deltaT = (((-1654.0*u -534.0)*u +111)*u +12.7)*u +5.7;
} }
else if (year < 1900) else if (year < 1900)
{ {
u = 1.15 + ub; u = 1.15 + ub;
//deltaT = -5.8 - 14.6*u + 27.0*std::pow(u,2) + 101.0*std::p ow(u,3) + 8234.0*std::pow(u,4);
deltaT = (((8234.0*u +101.0)*u +27.0)*u - 14.6)*u -5.8; deltaT = (((8234.0*u +101.0)*u +27.0)*u - 14.6)*u -5.8;
} }
else if (year < 1940) else if (year < 1940)
{ {
u = 0.80 + ub; u = 0.80 + ub;
//deltaT = +21.4 + 67.0*u - 443.0*std::pow(u,2) + 19.0*std:: pow(u,3) + 4441.0*std::pow(u,4);
deltaT = (((4441.0*u + 19.0)*u -443.0)*u +67.0)*u +21.4; deltaT = (((4441.0*u + 19.0)*u -443.0)*u +67.0)*u +21.4;
} }
else if (year < 1990) else if (year < 1990)
{ {
u = 0.35 + ub; u = 0.35 + ub;
//deltaT = +36.2 + 74.0*u + 189.0*std::pow(u,2) - 140.0*std: :pow(u,3) - 1883.0*std::pow(u,4);
deltaT = (((-1883.0*u -140.0)*u +189.0)*u +74.0)*u +36.2; deltaT = (((-1883.0*u -140.0)*u +189.0)*u +74.0)*u +36.2;
} }
else if (year <= 2000) else if (year <= 2000)
{ {
u = 0.05 + ub; u = 0.05 + ub;
//deltaT = +60.8 + 82.0*u - 188.0*std::pow(u,2) - 5034.0*std ::pow(u,3);
deltaT = ((-5034.0*u -188.0)*u +82.0)*u +60.8; deltaT = ((-5034.0*u -188.0)*u +82.0)*u +60.8;
} }
return deltaT; return deltaT;
} }
// Implementation of algorithm by Reingold & Dershowitz (Cal. Calc. 1997, 2 001, 2007, Cal. Tab. 2002) for DeltaT computation. // Implementation of algorithm by Reingold & Dershowitz (Cal. Calc. 1997, 2 001, 2007, Cal. Tab. 2002) for DeltaT computation.
// Created as yet another multi-segment polynomial fit through the table in Meeus: Astronomical Algorithms (1991). // Created as yet another multi-segment polynomial fit through the table in Meeus: Astronomical Algorithms (1991).
// Note that only the Third edition (2007) adds the 1700-1799 term. // Note that only the Third edition (2007) adds the 1700-1799 term.
// More efficient reimplementation with stricter adherence to the source. // More efficient reimplementation with stricter adherence to the source.
skipping to change at line 1813 skipping to change at line 1882
} }
// Implementation of algorithm by Banjevic (2006) for DeltaT computation. // Implementation of algorithm by Banjevic (2006) for DeltaT computation.
double getDeltaTByBanjevic(const double jDay) double getDeltaTByBanjevic(const double jDay)
{ {
int year, month, day; int year, month, day;
getDateFromJulianDay(jDay, &year, &month, &day); getDateFromJulianDay(jDay, &year, &month, &day);
double u, c; double u, c;
if (year>=-2020 && year<=-700) // Limited years!
year=qMax(-2020, qMin(year, 1620));
if (year<=-700)
{ {
u = (jDay-2378496.0)/36525.0; // 1800.0=1800-jan-0.5=2378496 .0 u = (jDay-2378496.0)/36525.0; // 1800.0=1800-jan-0.5=2378496 .0
c = 30.86; c = 30.86;
} }
else if (year>-700 && year<=1620) else // if (year>-700 && year<=1620)
{ {
u = (jDay-2385800.0)/36525.0; // 1820.0=1820-jan-0.5=2385800 .0 u = (jDay-2385800.0)/36525.0; // 1820.0=1820-jan-0.5=2385800 .0
c = 31; c = 31;
} }
else
{
u = 0.;
c = 0.;
}
return c*u*u; return c*u*u;
} }
// Implementation of algorithm by Islam, Sadiq & Qureshi (2008 + revisited 2013) for DeltaT computation. // Implementation of algorithm by Islam, Sadiq & Qureshi (2008 + revisited 2013) for DeltaT computation.
double getDeltaTByIslamSadiqQureshi(const double jDay) double getDeltaTByIslamSadiqQureshi(const double jDay)
{ {
int year, month, day; int year, month, day;
getDateFromJulianDay(jDay, &year, &month, &day); getDateFromJulianDay(jDay, &year, &month, &day);
double deltaT = 0.0; // Return deltaT = 0 outside valid range. double deltaT; // Return deltaT for the edge year outside valid rang e.
double u; double u;
const double ub=(jDay-2454101.0)/36525.0; // (2007-jan-0.5) const double ub=(jDay-2454101.0)/36525.0; // (2007-jan-0.5)
if (year >= 1620 && year <= 1698)
// Limited years!
year=qMax(1620, qMin(year, 2007));
if (year <= 1698)
{ {
u = 3.48 + ub; u = 3.48 + ub;
deltaT = (((1162.805 * u - 273.116) * u + 14.523) * u - 105. 262) * u + 38.067; deltaT = (((1162.805 * u - 273.116) * u + 14.523) * u - 105. 262) * u + 38.067;
} }
else if (year <= 1806) else if (year <= 1806)
{ {
u = 2.545 + ub; u = 2.545 + ub;
deltaT = (((-71.724 * u - 39.048) * u + 7.591) * u + 13.893) * u + 13.759; deltaT = (((-71.724 * u - 39.048) * u + 7.591) * u + 13.893) * u + 13.759;
} }
else if (year <= 1872) else if (year <= 1872)
skipping to change at line 1866 skipping to change at line 1937
{ {
u = 1.175 + ub; u = 1.175 + ub;
deltaT = (((6250.501 * u + 1006.463) * u + 139.921) * u - 2. 732) * u - 6.203; deltaT = (((6250.501 * u + 1006.463) * u + 139.921) * u - 2. 732) * u - 6.203;
} }
else if (year <= 1953) else if (year <= 1953)
{ {
// revised 2013 per email // revised 2013 per email
u = 0.77 + ub; u = 0.77 + ub;
deltaT = (((-390.785 * u + 901.514) * u - 88.044) * u + 8.99 7) * u + 24.006; deltaT = (((-390.785 * u + 901.514) * u - 88.044) * u + 8.99 7) * u + 24.006;
} }
else if (year <= 2007) else //if (year <= 2007)
{ {
// revised 2013 per email // revised 2013 per email
u = 0.265 + ub; u = 0.265 + ub;
deltaT = (((1314.759 * u - 296.018) * u - 101.898) * u + 88. 659) * u + 49.997; deltaT = (((1314.759 * u - 296.018) * u - 101.898) * u + 88. 659) * u + 49.997;
} }
return deltaT; return deltaT;
} }
// Implementation of polinomial approximation of time period 1620-2013 for DeltaT by M. Khalid, Mariam Sultana and Faheem Zaidi (2014). // Implementation of polinomial approximation of time period 1620-2013 for DeltaT by M. Khalid, Mariam Sultana and Faheem Zaidi (2014).
double getDeltaTByKhalidSultanaZaidi(const double jDay) double getDeltaTByKhalidSultanaZaidi(const double jDay)
{ {
int year, month, day; int year, month, day;
getDateFromJulianDay(jDay, &year, &month, &day); getDateFromJulianDay(jDay, &year, &month, &day);
double k, a0, a1, a2, a3, a4; //double a0, a1, a2, a3, a4;
if (year>=1620 && year<=1672) const float k[9] ={ 3.670f, 3.120f, 2.495f, 1.925f,
{ 1.525f, 1.220f, 0.880f, 0.455f, 0.115f};
k = 3.670; a0 = 76.541; a1 = -253.532; a2 = 695.901; a3 = -1 const float a0[9]={ 76.541f, 10.872f, 13.480f, 12.584f,
256.982; a4 = 627.152; 6.364f, -5.058f, 13.392f, 30.782f, 55.281f};
} const float a1[9]={ -253.532f, -40.744f, 13.075f, 1.929f,
else if (year>=1673 && year<=1729) 11.004f, -1.701f, 128.592f, 34.348f, 91.248f};
{ const float a2[9]={ 695.901f, 236.890f, 8.635f, 60.896f,
k = 3.120; a0 = 10.872; a1 = -40.744; a2 = 236.890; a3 = -35 407.776f, -46.403f, -279.165f, 46.452f, 87.202f};
1.537; a4 = 36.612; const float a3[9]={ -1256.982f, -351.537f, -3.307f, -1432.216f, -4
} 168.394f, -866.171f, -1282.050f, 1295.550f, -3092.565f};
else if (year>=1730 && year<=1797) const float a4[9]={ 627.152f, 36.612f, -128.294f, 3129.071f, 7
{ 561.686f, 5917.585f, 4039.490f, -3210.913f, 8255.422f};
k = 2.495; a0 = 13.480; a1 = 13.075; a2 = 8.635; a3 = -3.307 int i;
; a4 = -128.294; // Limited years! Deliver border values.
} year=qMax(1620, qMin(year, 2013));
else if (year>=1798 && year<=1843)
{ if (year<=1672)
k = 1.925; a0 = 12.584; a1 = 1.929; a2 = 60.896; a3 = -1432. i=0;
216; a4 = 3129.071; else if (year<=1729)
} i=1;
else if (year>=1844 && year<=1877) else if (year<=1797)
{ i=2;
k = 1.525; a0 = 6.364; a1 = 11.004; a2 = 407.776; a3 = -4168 else if (year<=1843)
.394; a4 = 7561.686; i=3;
} else if (year<=1877)
else if (year>=1878 && year<=1904) i=4;
{ else if (year<=1904)
k = 1.220; a0 = -5.058; a1 = -1.701; a2 = -46.403; a3 = -866 i=5;
.171; a4 = 5917.585; else if (year<=1945)
} i=6;
else if (year>=1905 && year<=1945) else if (year<=1989)
{ i=7;
k = 0.880; a0 = 13.392; a1 = 128.592; a2 = -279.165; a3 = -1 else // if (year<=2013)
282.050; a4 = 4039.490; i=8;
}
else if (year>=1946 && year<=1989) double u = k[i] + (year - 2000)/100;
{
k = 0.455; a0 = 30.782; a1 = 34.348; a2 = 46.452; a3 = 1295. return (((a4[i]*u + a3[i])*u + a2[i])*u + a1[i])*u + a0[i];
550; a4 = -3210.913; }
}
else if (year>=1990 && year<=2013) static const double StephensonMorrisonHohenkerk2016DeltaTtableS15[54][6]={
{ // Row Years Polynomial Coefficients
k = 0.115; a0 = 55.281; a1 = 91.248; a2 = 87.202; a3 = -3092 // i K_i K_{i+1} a_0 a_1 a_2 a
.565; a4 = 8255.422; _3
} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else - - -
/* 1 */ -720.0, 400.0, 20550.593, -21268.478, 11863.418,
-4541.129,
/* 2 */ 400.0, 1000.0, 6604.404, -5981.266, -505.093,
1349.609,
/* 3 */ 1000.0, 1500.0, 1467.654, -2452.187, 2460.927,
-1183.759,
/* 4 */ 1500.0, 1600.0, 292.635, -216.322, -43.614,
56.681,
/* 5 */ 1600.0, 1650.0, 89.380, -66.754, 31.607,
-10.497,
/* 6 */ 1650.0, 1720.0, 43.736, -49.043, 0.227,
15.811,
/* 7 */ 1720.0, 1800.0, 10.730, -1.321, 62.250,
-52.946,
/* 8 */ 1800.0, 1810.0, 18.714, -4.457, -1.509,
2.507,
/* 9 */ 1810.0, 1820.0, 15.255, 0.046, 6.012,
-4.634,
/* 10 */ 1820.0, 1830.0, 16.679, -1.831, -7.889,
3.799,
/* 11 */ 1830.0, 1840.0, 10.758, -6.211, 3.509,
-0.388,
/* 12 */ 1840.0, 1850.0, 7.668, -0.357, 2.345,
-0.338,
/* 13 */ 1850.0, 1855.0, 9.317, 1.659, 0.332,
-0.932,
/* 14 */ 1855.0, 1860.0, 10.376, -0.472, -2.463,
1.596,
/* 15 */ 1860.0, 1865.0, 9.038, -0.610, 2.325,
-2.497,
/* 16 */ 1865.0, 1870.0, 8.256, -3.450, -5.166,
2.729,
/* 17 */ 1870.0, 1875.0, 2.369, -5.596, 3.020,
-0.919,
/* 18 */ 1875.0, 1880.0, -1.126, -2.312, 0.264,
-0.037,
/* 19 */ 1880.0, 1885.0, -3.211, -1.894, 0.154,
0.562,
/* 20 */ 1885.0, 1890.0, -4.388, 0.101, 1.841,
-1.438,
/* 21 */ 1890.0, 1895.0, -3.884, -0.531, -2.473,
1.870,
/* 22 */ 1895.0, 1900.0, -5.017, 0.134, 3.138,
-0.232,
/* 23 */ 1900.0, 1905.0, -1.977, 5.715, 2.443,
-1.257,
/* 24 */ 1905.0, 1910.0, 4.923, 6.828, -1.329,
0.720,
/* 25 */ 1910.0, 1915.0, 11.142, 6.330, 0.831,
-0.825,
/* 26 */ 1915.0, 1920.0, 17.479, 5.518, -1.643,
0.262,
/* 27 */ 1920.0, 1925.0, 21.617, 3.020, -0.856,
0.008,
/* 28 */ 1925.0, 1930.0, 23.789, 1.333, -0.831,
0.127,
/* 29 */ 1930.0, 1935.0, 24.418, 0.052, -0.449,
0.142,
/* 30 */ 1935.0, 1940.0, 24.164, -0.419, -0.022,
0.702,
/* 31 */ 1940.0, 1945.0, 24.426, 1.645, 2.086,
-1.106,
/* 32 */ 1945.0, 1950.0, 27.050, 2.499, -1.232,
0.614,
/* 33 */ 1950.0, 1953.0, 28.932, 1.127, 0.220,
-0.277,
/* 34 */ 1953.0, 1956.0, 30.002, 0.737, -0.610,
0.631,
/* 35 */ 1956.0, 1959.0, 30.760, 1.409, 1.282,
-0.799,
/* 36 */ 1959.0, 1962.0, 32.652, 1.577, -1.115,
0.507,
/* 37 */ 1962.0, 1965.0, 33.621, 0.868, 0.406,
0.199,
/* 38 */ 1965.0, 1968.0, 35.093, 2.275, 1.002,
-0.414,
/* 39 */ 1968.0, 1971.0, 37.956, 3.035, -0.242,
0.202,
/* 40 */ 1971.0, 1974.0, 40.951, 3.157, 0.364,
-0.229,
/* 41 */ 1974.0, 1977.0, 44.244, 3.198, -0.323,
0.172,
/* 42 */ 1977.0, 1980.0, 47.291, 3.069, 0.193,
-0.192,
/* 43 */ 1980.0, 1983.0, 50.361, 2.878, -0.384,
0.081,
/* 44 */ 1983.0, 1986.0, 52.936, 2.354, -0.140,
-0.166,
/* 45 */ 1986.0, 1989.0, 54.984, 1.577, -0.637,
0.448,
/* 46 */ 1989.0, 1992.0, 56.373, 1.649, 0.709,
-0.277,
/* 47 */ 1992.0, 1995.0, 58.453, 2.235, -0.122,
0.111,
/* 48 */ 1995.0, 1998.0, 60.677, 2.324, 0.212,
-0.315,
/* 49 */ 1998.0, 2001.0, 62.899, 1.804, -0.732,
0.112,
/* 50 */ 2001.0, 2004.0, 64.082, 0.675, -0.396,
0.193,
/* 51 */ 2004.0, 2007.0, 64.555, 0.463, 0.184,
-0.008,
/* 52 */ 2007.0, 2010.0, 65.194, 0.809, 0.161,
-0.101,
/* 53 */ 2010.0, 2013.0, 66.063, 0.828, -0.142,
0.168,
/* 54 */ 2013.0, 2016.0, 66.917, 1.046, 0.360,
-0.282
};
double getDeltaTByStephensonMorrisonHohenkerk2016(const double jDay)
{
int year, month, day;
getDateFromJulianDay(jDay, &year, &month, &day);
double y=yearFraction(year, month, day);
if ((y<-720.) || (y>2016.))
{ {
k = 0.0; a0 = 0.0; a1 = 0.0; a2 = 0.0; a3 = 0.0; a4 = 0.0; double fact=(y-1825.0)/100.;
return -320.0+32.5*fact*fact;
} }
int i=0;
double u = k + (year - 2000)/100; while (StephensonMorrisonHohenkerk2016DeltaTtableS15[i][1]<y) i++;
Q_ASSERT(i<54);
return (((a4*u + a3)*u + a2)*u + a1)*u + a0; double t=(y-StephensonMorrisonHohenkerk2016DeltaTtableS15[i][0]) / (
StephensonMorrisonHohenkerk2016DeltaTtableS15[i][1]-StephensonMorrisonHohen
kerk2016DeltaTtableS15[i][0]);
return ((StephensonMorrisonHohenkerk2016DeltaTtableS15[i][5]*t + Ste
phensonMorrisonHohenkerk2016DeltaTtableS15[i][4])*t
+ StephensonMorrisonHohenkerk2016DeltaTtableS15[i][3])*t + S
tephensonMorrisonHohenkerk2016DeltaTtableS15[i][2];
} }
double getMoonSecularAcceleration(const double jDay, const double nd, const bool useDE43x) double getMoonSecularAcceleration(const double jDay, const double nd, const bool useDE43x)
{ {
int year, month, day; int year, month, day;
getDateFromJulianDay(jDay, &year, &month, &day); getDateFromJulianDay(jDay, &year, &month, &day);
double t = (getDecYear(year, month, day)-1955.5)/100.0; double t = (getDecYear(year, month, day)-1955.5)/100.0;
// n.dot for secular acceleration of the Moon in ELP2000-82B // n.dot for secular acceleration of the Moon in ELP2000-82B
// have value -23.8946 "/cy/cy (or -25.8 for DE43x usage) // have value -23.8946 "/cy/cy (or -25.8 for DE43x usage)
 End of changes. 32 change blocks. 
91 lines changed or deleted 290 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/