StelUtils.cpp   StelUtils.cpp 
skipping to change at line 491 skipping to change at line 491
return 0; return 0;
QStringList list = reg.capturedTexts(); QStringList list = reg.capturedTexts();
bool sign = (list[1] == "+"); bool sign = (list[1] == "+");
int deg = list[2].toInt(); int deg = list[2].toInt();
int min = list[3].toInt(); int min = list[3].toInt();
int sec = list[4].toInt(); int sec = list[4].toInt();
return dmsToRad(sign ? deg : -deg, min, sec); return dmsToRad(sign ? deg : -deg, min, sec);
} }
Vec2f strToVec2f(const QStringList &s)
{
if (s.size()<2)
return Vec2f(0.f,0.f);
return Vec2f(s[0].toFloat(),s[1].toFloat());
}
Vec2f strToVec2f(const QString &s)
{
return strToVec2f(s.split(","));
}
// Obtains a Vec3f from a string with the form x,y,z // Obtains a Vec3f from a string with the form x,y,z
Vec3f strToVec3f(const QStringList& s) Vec3f strToVec3f(const QStringList& s)
{ {
if (s.size()<3) if (s.size()<3)
return Vec3f(0.f,0.f,0.f); return Vec3f(0.f,0.f,0.f);
return Vec3f(s[0].toFloat(),s[1].toFloat(),s[2].toFloat()); return Vec3f(s[0].toFloat(),s[1].toFloat(),s[2].toFloat());
} }
Vec3f strToVec3f(const QString& s) Vec3f strToVec3f(const QString& s)
skipping to change at line 518 skipping to change at line 531
return Vec4d(0.0,0.0,0.0,0.0); return Vec4d(0.0,0.0,0.0,0.0);
return Vec4d(s[0].toDouble(), s[1].toDouble(), s[2].toDouble(), s[3] .toDouble()); return Vec4d(s[0].toDouble(), s[1].toDouble(), s[2].toDouble(), s[3] .toDouble());
} }
Vec4d strToVec4d(const QString& str) Vec4d strToVec4d(const QString& str)
{ {
return strToVec4d(str.split(",")); return strToVec4d(str.split(","));
} }
QString vec2fToStr(const Vec2f &v)
{
return QString("%1,%2")
.arg(v[0],0,'f',6)
.arg(v[1],0,'f',6);
}
QString vec3fToStr(const Vec3f &v) QString vec3fToStr(const Vec3f &v)
{ {
return QString("%1,%2,%3") return QString("%1,%2,%3")
.arg(v[0],0,'f',6) .arg(v[0],0,'f',6)
.arg(v[1],0,'f',6) .arg(v[1],0,'f',6)
.arg(v[2],0,'f',6); .arg(v[2],0,'f',6);
} }
QString vec4dToStr(const Vec4d &v) QString vec4dToStr(const Vec4d &v)
{ {
skipping to change at line 802 skipping to change at line 822
if(millis) if(millis)
{ {
*millis = (int)floor((secs - floor(secs)) * 1000.0); *millis = (int)floor((secs - floor(secs)) * 1000.0);
} }
} }
QString julianDayToISO8601String(const double jd, bool addMS) QString julianDayToISO8601String(const double jd, bool addMS)
{ {
int year, month, day, hour, minute, second,millis; int year, month, day, hour, minute, second,millis;
getDateFromJulianDay(jd, &year, &month, &day); getDateFromJulianDay(jd, &year, &month, &day);
getTimeFromJulianDay(jd, &hour, &minute, &second, addMS ? &millis : NULL ); getTimeFromJulianDay(jd, &hour, &minute, &second, addMS ? &millis : Q_NULLPTR );
QString res = QString("%1-%2-%3T%4:%5:%6") QString res = QString("%1-%2-%3T%4:%5:%6")
.arg((year >= 0 ? year : -1* year),4,10,QLa tin1Char('0')) .arg((year >= 0 ? year : -1* year),4,10,QLa tin1Char('0'))
.arg(month,2,10,QLatin1Char('0')) .arg(month,2,10,QLatin1Char('0'))
.arg(day,2,10,QLatin1Char('0')) .arg(day,2,10,QLatin1Char('0'))
.arg(hour,2,10,QLatin1Char('0')) .arg(hour,2,10,QLatin1Char('0'))
.arg(minute,2,10,QLatin1Char('0')) .arg(minute,2,10,QLatin1Char('0'))
.arg(second,2,10,QLatin1Char('0')); .arg(second,2,10,QLatin1Char('0'));
if(addMS) if(addMS)
skipping to change at line 965 skipping to change at line 985
} }
//! use QDateTime to get a Julian Date from the system's current time. //! use QDateTime to get a Julian Date from the system's current time.
//! this is an acceptable use of QDateTime because the system's current //! this is an acceptable use of QDateTime because the system's current
//! time is more than likely always going to be expressible by QDateTime. //! time is more than likely always going to be expressible by QDateTime.
double getJDFromSystem() double getJDFromSystem()
{ {
return qDateTimeToJd(QDateTime::currentDateTime().toUTC()); return qDateTimeToJd(QDateTime::currentDateTime().toUTC());
} }
double getJDFromBesselianEpoch(const float epoch)
{
return 2400000.5 + (15019.81352 + (epoch - 1900.0) * 365.242198781);
}
double qTimeToJDFraction(const QTime& time) double qTimeToJDFraction(const QTime& time)
{ {
return (double)1./(24*60*60*1000)*QTime(0, 0, 0, 0).msecsTo(time)-0. 5; return (double)1./(24*60*60*1000)*QTime(0, 0, 0, 0).msecsTo(time)-0. 5;
} }
QTime jdFractionToQTime(const double jd) QTime jdFractionToQTime(const double jd)
{ {
double decHours = std::fmod(jd+0.5, 1.0); double decHours = std::fmod(jd+0.5, 1.0);
int hours = (int)(decHours/0.041666666666666666666); int hours = (int)(decHours/0.041666666666666666666);
int mins = (int)((decHours-(hours*0.041666666666666666666))/0.000694 44444444444444444); int mins = (int)((decHours-(hours*0.041666666666666666666))/0.000694 44444444444444444);
skipping to change at line 1529 skipping to change at line 1554
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. STRICTLY 1800...1975 ONLY!! Now delivers values for the edges. // 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. u=qBound(-1.0, u, 0.76); // Limit range to 1800...1975. Else we hav e 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! // Limited years!
year=qMax(-391, qMin(year, 1600)); year=qBound(-391, 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;
} }
skipping to change at line 1580 skipping to change at line 1605
double getDeltaTByStephensonHoulden(const double jDay) double getDeltaTByStephensonHoulden(const double jDay)
{ {
// TODO FIXME: GZ 2016-12: WHAT IS THIS?? Stephenson-Houlden 1986 ha s a different Formula!! // TODO FIXME: GZ 2016-12: WHAT IS THIS?? Stephenson-Houlden 1986 ha s a different Formula!!
// 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);
// double yeardec=getDecYear(year, month, day); // double yeardec=getDecYear(year, month, day);
// // Limited years!? // // Limited years!?
// year=qMax(-600, qMin(year, 1600)); // year=qBound(-600, year, 1600);
// if (year <= 948) // if (year <= 948)
// { // {
// u = (yeardec-948)/100; // u = (yeardec-948)/100;
// deltaT = (46.5*u -405.0)*u + 1830.0; // deltaT = (46.5*u -405.0)*u + 1830.0;
// } // }
// if (948 < year && year <= 1600) // if (948 < year && year <= 1600)
// { // {
// u = (yeardec-1850)/100; // u = (yeardec-1850)/100;
// deltaT = 22.5*u*u; // deltaT = 22.5*u*u;
skipping to change at line 1618 skipping to change at line 1643
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. STRICTLY 1800...1988 ONLY!! Now delivers values for the edges. // 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. u=qBound(-1.0, u, 0.89); // Limit range to 1800...1988. Else we hav e 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! // Limited years!
year=qMax(-391, qMin(year, 1600)); year=qBound(-391, 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! // Limited years!
year=qMax(-2999, qMin(year, 1620)); year=qBound(-2999, 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 1883 skipping to change at line 1908
// 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;
// Limited years! // Limited years!
year=qMax(-2020, qMin(year, 1620)); year=qBound(-2020, year, 1620);
if (year<=-700) 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;
skipping to change at line 1909 skipping to change at line 1934
// 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; // Return deltaT for the edge year outside valid rang e. 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)
// Limited years! // Limited years!
year=qMax(1620, qMin(year, 2007)); year=qBound(1620, year, 2007);
if (year <= 1698) 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;
skipping to change at line 1961 skipping to change at line 1986
getDateFromJulianDay(jDay, &year, &month, &day); getDateFromJulianDay(jDay, &year, &month, &day);
//double a0, a1, a2, a3, a4; //double a0, a1, a2, a3, a4;
const float k[9] ={ 3.670f, 3.120f, 2.495f, 1.925f, 1.525f, 1.220f, 0.880f, 0.455f, 0.115f}; const float k[9] ={ 3.670f, 3.120f, 2.495f, 1.925f, 1.525f, 1.220f, 0.880f, 0.455f, 0.115f};
const float a0[9]={ 76.541f, 10.872f, 13.480f, 12.584f, 6.364f, -5.058f, 13.392f, 30.782f, 55.281f}; const float a0[9]={ 76.541f, 10.872f, 13.480f, 12.584f, 6.364f, -5.058f, 13.392f, 30.782f, 55.281f};
const float a1[9]={ -253.532f, -40.744f, 13.075f, 1.929f, 11.004f, -1.701f, 128.592f, 34.348f, 91.248f}; const float a1[9]={ -253.532f, -40.744f, 13.075f, 1.929f, 11.004f, -1.701f, 128.592f, 34.348f, 91.248f};
const float a2[9]={ 695.901f, 236.890f, 8.635f, 60.896f, 407.776f, -46.403f, -279.165f, 46.452f, 87.202f}; const float a2[9]={ 695.901f, 236.890f, 8.635f, 60.896f, 407.776f, -46.403f, -279.165f, 46.452f, 87.202f};
const float a3[9]={ -1256.982f, -351.537f, -3.307f, -1432.216f, -4 168.394f, -866.171f, -1282.050f, 1295.550f, -3092.565f}; const float a3[9]={ -1256.982f, -351.537f, -3.307f, -1432.216f, -4 168.394f, -866.171f, -1282.050f, 1295.550f, -3092.565f};
const float a4[9]={ 627.152f, 36.612f, -128.294f, 3129.071f, 7 561.686f, 5917.585f, 4039.490f, -3210.913f, 8255.422f}; const float a4[9]={ 627.152f, 36.612f, -128.294f, 3129.071f, 7 561.686f, 5917.585f, 4039.490f, -3210.913f, 8255.422f};
int i; int i;
// Limited years! Deliver border values. // Limited years! Deliver border values.
year=qMax(1620, qMin(year, 2013)); year=qBound(1620, year, 2013);
if (year<=1672) if (year<=1672)
i=0; i=0;
else if (year<=1729) else if (year<=1729)
i=1; i=1;
else if (year<=1797) else if (year<=1797)
i=2; i=2;
else if (year<=1843) else if (year<=1843)
i=3; i=3;
else if (year<=1877) else if (year<=1877)
 End of changes. 13 change blocks. 
10 lines changed or deleted 35 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/