Observability.cpp   Observability.cpp 
skipping to change at line 195 skipping to change at line 195
msgS = q_("s"); msgS = q_("s");
msgSetsAt = q_("Sets at %1 (in %2)"); msgSetsAt = q_("Sets at %1 (in %2)");
msgRoseAt = q_("Rose at %1 (%2 ago)"); msgRoseAt = q_("Rose at %1 (%2 ago)");
msgSetAt = q_("Set at %1 (%2 ago)"); msgSetAt = q_("Set at %1 (%2 ago)");
msgRisesAt = q_("Rises at %1 (in %2)"); msgRisesAt = q_("Rises at %1 (in %2)");
msgCircumpolar = q_("Circumpolar."); msgCircumpolar = q_("Circumpolar.");
msgNoRise = q_("No rise."); msgNoRise = q_("No rise.");
msgCulminatesAt = q_("Culminates at %1 (in %2) at %3 deg."); msgCulminatesAt = q_("Culminates at %1 (in %2) at %3 deg.");
msgCulminatedAt = q_("Culminated at %1 (%2 ago) at %3 deg."); msgCulminatedAt = q_("Culminated at %1 (%2 ago) at %3 deg.");
msgSrcNotObs = q_("Source is not observable."); msgSrcNotObs = q_("Source is not observable.");
msgNoACRise = q_("No acronychal nor cosmical rise/set."); msgNoACRise = q_("No Acronychal nor Cosmical rise/set.");
msgGreatElong = q_("Greatest elongation: %1 (at %2 deg.)"); msgGreatElong = q_("Greatest elongation: %1 (at %2 deg.)");
msgLargSSep = q_("Largest Sun separation: %1 (at %2 deg.)"); msgLargSSep = q_("Largest Sun separation: %1 (at %2 deg.)");
msgNone = q_("None"); msgNone = q_("None");
// TRANSLATORS: The space at the end is significant - another senten ce may follow. // TRANSLATORS: The space at the end is significant - another senten ce may follow.
msgAcroRise = q_("Acronychal rise/set: %1/%2. "); msgAcroRise = q_("Acronycal rise/set: %1/%2. ");
msgHeliRise = q_("Heliacal rise/set: %1/%2. ");
msgNoHeliRise = q_("No Heliacal rise/set. ");
// TRANSLATORS: The space at the end is significant - another senten ce may follow. // TRANSLATORS: The space at the end is significant - another senten ce may follow.
msgNoAcroRise = q_("No acronychal rise/set. "); msgNoAcroRise = q_("No Acronycal rise/set. ");
msgCosmRise = q_("Cosmical rise/set: %1/%2."); msgCosmRise = q_("Cosmical rise/set: %1/%2.");
msgNoCosmRise = q_("No cosmical rise/set."); msgNoCosmRise = q_("No Cosmical rise/set.");
msgWholeYear = q_("Observable during the whole year."); msgWholeYear = q_("Observable during the whole year.");
msgNotObs = q_("Not observable at dark night."); msgNotObs = q_("Not observable at dark night.");
msgAboveHoriz = q_("Nights above horizon: %1"); msgAboveHoriz = q_("Nights above horizon: %1");
msgToday = q_("TODAY:"); msgToday = q_("TODAY:");
msgThisYear = q_("THIS YEAR:"); msgThisYear = q_("THIS YEAR:");
// TRANSLATORS: The space at the end is significant - another senten ce may follow. // TRANSLATORS: The space at the end is significant - another senten ce may follow.
msgPrevFullMoon = q_("Previous Full Moon: %1 %2 at %3:%4. "); msgPrevFullMoon = q_("Previous Full Moon: %1 %2 at %3:%4. ");
msgNextFullMoon = q_("Next Full Moon: %1 %2 at %3:%4. "); msgNextFullMoon = q_("Next Full Moon: %1 %2 at %3:%4. ");
} }
skipping to change at line 338 skipping to change at line 340
// Add refraction, if necessary: // Add refraction, if necessary:
Vec3d TempRefr; Vec3d TempRefr;
TempRefr[0] = std::cos(horizonAltitude); TempRefr[0] = std::cos(horizonAltitude);
TempRefr[1] = 0.0; TempRefr[1] = 0.0;
TempRefr[2] = std::sin(horizonAltitude); TempRefr[2] = std::sin(horizonAltitude);
Vec3d CorrRefr = core->altAzToEquinoxEqu(TempRefr,StelCore::Refracti onAuto); Vec3d CorrRefr = core->altAzToEquinoxEqu(TempRefr,StelCore::Refracti onAuto);
TempRefr = core->equinoxEquToAltAz(CorrRefr,StelCore::RefractionOff) ; TempRefr = core->equinoxEquToAltAz(CorrRefr,StelCore::RefractionOff) ;
double RefracAlt = std::asin(TempRefr[2]); double RefracAlt = std::asin(TempRefr[2]);
// If the diference is larger than 1 arcminute... // If the diference is larger than 1 arcminute...
if (std::abs(refractedHorizonAlt-RefracAlt)>2.91e-4) if (qAbs(refractedHorizonAlt-RefracAlt)>2.91e-4)
{ {
//... configuration for refraction changed notably. //... configuration for refraction changed notably.
refractedHorizonAlt = RefracAlt; refractedHorizonAlt = RefracAlt;
configChanged = true; configChanged = true;
souChanged = true; souChanged = true;
}; };
// If we have changed latitude (or year), we update the vector of Sun's hou r // If we have changed latitude (or year), we update the vector of Sun's hou r
// angles at twilight, and re-compute Sun/Moon ephemeris (if selected): // angles at twilight, and re-compute Sun/Moon ephemeris (if selected):
if (locChanged || yearChanged || configChanged) if (locChanged || yearChanged || configChanged)
skipping to change at line 482 skipping to change at line 484
{ {
// Today's ephemeris (rise, set, and transit times) // Today's ephemeris (rise, set, and transit times)
if (!isStar) if (!isStar)
{ {
int type = (isSun) ? 1:0; int type = (isSun) ? 1:0;
type += (isMoon) ? 2:0; type += (isMoon) ? 2:0;
type += (!isSun && !isMoon) ? 3:0; type += (!isSun && !isMoon) ? 3:0;
// Returns false if the calculation fails... // Returns false if the calculation fails...
solvedMoon = calculateSolarSystemEvents(core, type); solvedMoon = calculateSolarSystemEvents(core, type);
currH = std::abs(24.*(MoonCulm-myJD)/TFrac); currH = qAbs(24.*(MoonCulm-myJD)/TFrac);
transit = MoonCulm-myJD<0.0; transit = MoonCulm-myJD<0.0;
if (solvedMoon) if (solvedMoon)
{ // If failed, Set and Rise will be dummy. { // If failed, Set and Rise will be dummy.
settingTime = std::abs(24.*(MoonSet-myJD)/TF settingTime = qAbs(24.*(MoonSet-myJD)/TFrac)
rac); ;
risingTime = std::abs(24.*(MoonRise-myJD)/TF risingTime = qAbs(24.*(MoonRise-myJD)/TFrac)
rac); ;
} }
} }
else if (horizH>0.0) else if (horizH>0.0)
{ // The source is not circumpolar and can be seen from this latitude. { // The source is not circumpolar and can be seen from this latitude.
if ( LocPos[1]>0.0 ) // The source is at the eastern side... if ( LocPos[1]>0.0 ) // The source is at the eastern side...
{ {
if ( currH>horizH ) // ... and below the hor izon. if ( currH>horizH ) // ... and below the hor izon.
{ {
settingTime = 24.-currH-horizH; settingTime = 24.-currH-horizH;
skipping to change at line 578 skipping to change at line 580
else // The source is either circumpolar or never rises: else // The source is either circumpolar or never rises:
{ {
(alti>refractedHorizonAlt)? RS1 = msgCircumpolar: RS 1 = msgNoRise; (alti>refractedHorizonAlt)? RS1 = msgCircumpolar: RS 1 = msgNoRise;
RS2 = ""; RS2 = "";
}; };
// Culmination: // Culmination:
if (isStar) if (isStar)
{ {
culmAlt = std::abs(mylat-selDec); // 90.-altitude at transit. culmAlt = qAbs(mylat-selDec); // 90.-altitude at tra nsit.
transit = LocPos[1]<0.0; transit = LocPos[1]<0.0;
}; };
if (culmAlt < (halfpi - refractedHorizonAlt)) // Source can be observed. if (culmAlt < (halfpi - refractedHorizonAlt)) // Source can be observed.
{ {
double altiAtCulmi = Rad2Deg*(halfpi-culmAlt-refract edHorizonAlt); double altiAtCulmi = Rad2Deg*(halfpi-culmAlt-refract edHorizonAlt);
double2hms(TFrac*currH,dc,mc,sc); double2hms(TFrac*currH,dc,mc,sc);
//String with the time span for culmination: //String with the time span for culmination:
Cul = (dc==0)?"":QString("%1%2 ").arg(dc).arg(msgH); Cul = (dc==0)?"":QString("%1%2 ").arg(dc).arg(msgH);
skipping to change at line 653 skipping to change at line 655
lineBestNight.clear(); lineBestNight.clear();
lineObservableRange.clear(); lineObservableRange.clear();
// Check if the target cannot be seen. // Check if the target cannot be seen.
if (culmAlt >= (halfpi - refractedHorizonAlt)) if (culmAlt >= (halfpi - refractedHorizonAlt))
{ {
//ObsRange = q_("Source is not observable.") ; //ObsRange = q_("Source is not observable.") ;
//AcroCos = q_("No Acronychal nor Cosmical r ise/set."); //AcroCos = q_("No Acronychal nor Cosmical r ise/set.");
lineObservableRange = msgSrcNotObs; lineObservableRange = msgSrcNotObs;
lineAcroCos = msgNoACRise; lineAcroCos = msgNoACRise;
lineHeli = msgNoHeliRise;
} }
else else
{ // Source can be seen. { // Source can be seen.
/////////////////////////// ///////////////////////////
// - Part 1. Determine the best observing night (i.e., opposition to the Su n): // - Part 1. Determine the best observing night (i.e., opposition to the Su n):
if (show_Best_Night) if (show_Best_Night)
{ {
int selday = 0; int selday = 0;
double deltaPhs = -1.0; // Initial d ummy value double deltaPhs = -1.0; // Initial d ummy value
skipping to change at line 694 skipping to change at line 697
lineBestNight = lineBestNight lineBestNight = lineBestNight
.arg(formatAsDate(se lday)) .arg(formatAsDate(se lday))
.arg(deltaPhs*Rad2De g, 0, 'f', 1); .arg(deltaPhs*Rad2De g, 0, 'f', 1);
} }
/////////////////////////////// ///////////////////////////////
// - Part 2. Determine Acronychal and Cosmical rise and set: // - Part 2. Determine Acronychal and Cosmical rise and set:
if (show_AcroCos) if (show_AcroCos)
{ {
int acroRise, acroSet, cosRise, cosS int acroRise, acroSet, cosRise, cosS
et; et, heliRise, heliSet;
int result = calculateAcroCos(acroRi se, acroSet, int result = calculateAcroCos(acroRi se, acroSet,
cosRis e, cosSet); cosRis e, cosSet);
int resultHeli = calculateHeli(0,hel
iRise,heliSet);
QString acroRiseStr, acroSetStr; QString acroRiseStr, acroSetStr;
QString cosRiseStr, cosSetStr; QString cosRiseStr, cosSetStr;
QString heliRiseStr, heliSetStr;
// TODO: Possible error? Day 0 is 1 Jan. // TODO: Possible error? Day 0 is 1 Jan.
acroRiseStr = (acroRise>0)?formatAsD ate(acroRise):msgNone; acroRiseStr = (acroRise>0)?formatAsD ate(acroRise):msgNone;
acroSetStr = (acroSet>0)?formatAsDat e(acroSet):msgNone; acroSetStr = (acroSet>0)?formatAsDat e(acroSet):msgNone;
cosRiseStr = (cosRise>0)?formatAsDat e(cosRise):msgNone; cosRiseStr = (cosRise>0)?formatAsDat e(cosRise):msgNone;
cosSetStr = (cosSet>0)?formatAsDate( cosSet):msgNone; cosSetStr = (cosSet>0)?formatAsDate( cosSet):msgNone;
heliRiseStr = (heliRise>0)?formatAsD
ate(heliRise):msgNone;
heliSetStr = (heliSet>0)?formatAsDat
e(heliSet):msgNone;
if (result==3 || result==1) if (result==3 || result==1)
lineAcroCos = msgAcroRise lineAcroCos = msgAcroRise
.arg(acroRise Str) .arg(acroRise Str)
.arg(acroSetS tr); .arg(acroSetS tr);
else else
lineAcroCos = msgNoAcroRise ; lineAcroCos = msgNoAcroRise ;
if (result==3 || result==2) if (result==3 || result==2)
lineAcroCos += msgCosmRise lineAcroCos += msgCosmRise
.arg(cosRiseS tr) .arg(cosRiseS tr)
.arg(cosSetSt r); .arg(cosSetSt r);
else else
lineAcroCos += msgNoCosmRise ; lineAcroCos += msgNoCosmRise ;
if (resultHeli==1)
lineHeli = msgHeliRise.arg(h
eliRiseStr).arg(heliSetStr);
else
lineHeli = msgNoHeliRise;
} }
//////////////////////////// ////////////////////////////
// - Part 3. Determine range of good nights // - Part 3. Determine range of good nights
// (i.e., above horizon before/after twilight): // (i.e., above horizon before/after twilight):
if (show_Good_Nights) if (show_Good_Nights)
{ {
int selday = 0; int selday = 0;
int selday2 = 0; int selday2 = 0;
bool bestBegun = false; // Are we in side a good time range? bool bestBegun = false; // Are we in side a good time range?
bool atLeastOne = false; bool atLeastOne = false;
QString dateRange; QString dateRange;
bool poleNight, twiGood; bool poleNight, twiGood;
for (int i=0; i<nDays; i++) for (int i=0; i<nDays; i++)
{ {
poleNight = sunSidT[0][i]<0. poleNight = sunSidT[0][i]<0.
0 && std::abs(sunDec[i]-mylat)>=halfpi; // Is it night during 24h? 0 && qAbs(sunDec[i]-mylat)>=halfpi; // Is it night during 24h?
twiGood = (poleNight && std: twiGood = (poleNight && qAbs
:abs(objectDec[i]-mylat)<halfpi)?true:CheckRise(i); (objectDec[i]-mylat)<halfpi)?true:CheckRise(i);
if (twiGood && bestBegun == false) if (twiGood && bestBegun == false)
{ {
selday = i; selday = i;
bestBegun = true; bestBegun = true;
atLeastOne = true; atLeastOne = true;
}; };
if (!twiGood && bestBegun == true) if (!twiGood && bestBegun == true)
{ {
skipping to change at line 827 skipping to change at line 842
} }
if (show_Good_Nights) if (show_Good_Nights)
{ {
yLine -= lineSpacing; yLine -= lineSpacing;
painter.drawText(xLine + fontSize, yLine, lineObserv ableRange); painter.drawText(xLine + fontSize, yLine, lineObserv ableRange);
} }
if (show_AcroCos) if (show_AcroCos)
{ {
yLine -= lineSpacing; yLine -= lineSpacing;
painter.drawText(xLine + fontSize, yLine, lineAcroCo s); painter.drawText(xLine + fontSize, yLine, lineAcroCo s);
yLine -= lineSpacing;
painter.drawText(xLine + fontSize, yLine, lineHeli);
} }
} }
} }
// END OF MAIN CODE // END OF MAIN CODE
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
////////////////////////////// //////////////////////////////
// AUXILIARY FUNCTIONS // AUXILIARY FUNCTIONS
//////////////////////////////////// ////////////////////////////////////
// Returns the hour angle for a given altitude: // Returns the hour angle for a given altitude:
double Observability::calculateHourAngle(double latitude, double Observability::calculateHourAngle(double latitude,
double elevation, double elevation,
double declination) double declination)
{ {
double denom = std::cos(latitude)*std::cos(declination); double denom = std::cos(latitude)*std::cos(declination);
double numer = (std::sin(elevation)-std::sin(latitude)*std::sin(decl ination)); double numer = (std::sin(elevation)-std::sin(latitude)*std::sin(decl ination));
if ( std::abs(numer) > std::abs(denom) ) if ( qAbs(numer) > qAbs(denom) )
{ {
return -0.5/86400.; // Source doesn't reach that altitude. return -0.5/86400.; // Source doesn't reach that altitude.
} }
else else
{ {
return Rad2Hr * std::acos(numer/denom); return Rad2Hr * std::acos(numer/denom);
} }
} }
//////////////////////////////////// ////////////////////////////////////
skipping to change at line 882 skipping to change at line 899
return result; return result;
} }
//////////////////////////////////// ////////////////////////////////////
//////////////////////////////////// ////////////////////////////////////
// Converts a float time/angle span (in hours/degrees) in the (integer) for mat hh/dd,mm,ss: // Converts a float time/angle span (in hours/degrees) in the (integer) for mat hh/dd,mm,ss:
void Observability::double2hms(double hfloat, int &h1, int &h2, int &h3) void Observability::double2hms(double hfloat, int &h1, int &h2, int &h3)
{ {
double f1,f2,f3; double f1,f2,f3;
hfloat = std::abs(hfloat); hfloat = qAbs(hfloat);
double ffrac = std::modf(hfloat,&f1); double ffrac = std::modf(hfloat,&f1);
double ffrac2 = std::modf(60.*ffrac,&f2); double ffrac2 = std::modf(60.*ffrac,&f2);
ffrac2 = std::modf(3600.*(ffrac-f2/60.),&f3); ffrac2 = std::modf(3600.*(ffrac-f2/60.),&f3);
h1 = (int)f1 ; h2 = (int)std::abs(f2+0.0*ffrac2) ; h3 = (int)std::ab s(f3); h1 = (int)f1 ; h2 = (int)qAbs(f2+0.0*ffrac2) ; h3 = (int)qAbs(f3);
} }
//////////////////////////////////// ////////////////////////////////////
//////////////////////////////////// ////////////////////////////////////
// Adds/subtracts 24hr to ensure a RA between 0 and 24hr: // Adds/subtracts 24hr to ensure a RA between 0 and 24hr:
double Observability::toUnsignedRA(double RA) double Observability::toUnsignedRA(double RA)
{ {
double tempRA,tempmod; double tempRA,tempmod;
//FIXME: tempmod is unused variable; need fix if (RA<0.0)
if (RA<0.0) {tempmod = std::modf(-RA/24.,&tempRA); RA += 24.*(tempRA {
+1.0)+0.0*tempmod;}; tempmod = std::modf(-RA/24.,&tempRA);
RA += 24.*(tempRA+1.0)+0.0*tempmod;
};
double auxRA = 24.*std::modf(RA/24.,&tempRA); double auxRA = 24.*std::modf(RA/24.,&tempRA);
auxRA += (auxRA<0.0)?24.0:((auxRA>24.0)?-24.0:0.0); auxRA += (auxRA<0.0)?24.0:((auxRA>24.0)?-24.0:0.0);
return auxRA; return auxRA;
} }
//////////////////////////////////// ////////////////////////////////////
QString Observability::formatAsDate(int dayNumber) QString Observability::formatAsDate(int dayNumber)
{ {
int day, month, year; int day, month, year;
StelUtils::getDateFromJulianDay(yearJD[dayNumber], &year, &month, &d ay); StelUtils::getDateFromJulianDay(yearJD[dayNumber], &year, &month, &d ay);
skipping to change at line 1059 skipping to change at line 1079
int nBin = 1000; int nBin = 1000;
double auxSid1 = sunSidT[0][day]; double auxSid1 = sunSidT[0][day];
auxSid1 += (sunSidT[0][day] < sunSidT[1][day]) ? 24.0 : 0.0; auxSid1 += (sunSidT[0][day] < sunSidT[1][day]) ? 24.0 : 0.0;
double deltaT = (auxSid1-sunSidT[1][day]) / ((double)nBin); double deltaT = (auxSid1-sunSidT[1][day]) / ((double)nBin);
double hour; double hour;
for (int j=0; j<nBin; j++) for (int j=0; j<nBin; j++)
{ {
hour = toUnsignedRA(sunSidT[1][day]+deltaT*(double)j - objec tRA[day]); hour = toUnsignedRA(sunSidT[1][day]+deltaT*(double)j - objec tRA[day]);
hour -= (hour>12.) ? 24.0 : 0.0; hour -= (hour>12.) ? 24.0 : 0.0;
if (std::abs(hour)<objectH0[day] || (objectH0[day] < 0.0 && alti>0.0)) if (qAbs(hour)<objectH0[day] || (objectH0[day] < 0.0 && alti >0.0))
return true; return true;
} }
return false; return false;
} }
/////////////////////////////////////////// ///////////////////////////////////////////
/////////////////////////////////////////// ///////////////////////////////////////////
// Finds the dates of Acronichal (Rise, Set) and Cosmical (Rise2, Set2) dat es. // Finds the dates of Acronichal (Rise, Set) and Cosmical (Rise2, Set2) dat es.
int Observability::calculateHeli(int imethod, int &heliRise, int &heliSet)
{
Q_UNUSED(imethod)
heliRise = -1;
heliSet = -1;
double bestDiffHeliRise = 12.0;
double bestDiffHeliSet = 12.0;
double hourDiffHeliRise, hourDiffHeliSet;
bool success = false;
for (int i=0; i<366; i++)
{
if (objectH0[i]>0.0 && sunSidT[0][i]>0.0 && sunSidT[1][i]>0.
0)
{
success = true;
hourDiffHeliRise = toUnsignedRA(objectRA[i] - object
H0[i]);
// hourDiffCosRise = hourDiffAcroRise-sunSidT[0][i];
hourDiffHeliRise -= sunSidT[0][i];
hourDiffHeliSet = toUnsignedRA(objectRA[i] + objectH
0[i]);
// hourCosDiffSet = hourDiffAcroSet - sunSidT[1][i];
hourDiffHeliSet -= sunSidT[1][i];
// Heliacal rise/set:
if (qAbs(hourDiffHeliRise) < bestDiffHeliRise)
{
bestDiffHeliRise = qAbs(hourDiffHeliRise);
heliRise = i;
};
if (qAbs(hourDiffHeliSet) < bestDiffHeliSet)
{
bestDiffHeliSet = qAbs(hourDiffHeliSet);
heliSet = i;
};
};
};
heliRise *= (bestDiffHeliRise > 0.083)?-1:1; // Check that differenc
e is lower than 5 minutes.
heliSet *= (bestDiffHeliSet > 0.083)?-1:1; // Check that difference
is lower than 5 minutes.
int result = (heliRise>0 || heliSet>0) ? 1 : 0;
return (success) ? result : 0;
};
///////////////////////////////////////////
// Finds the dates of Acronichal (Rise, Set) and Cosmical (Rise2, Set2) dat
es.
int Observability::calculateAcroCos(int &acroRise, int &acroSet, int Observability::calculateAcroCos(int &acroRise, int &acroSet,
int &cosRise, int &cosSet) int &cosRise, int &cosSet)
{ {
acroRise = -1; acroRise = -1;
acroSet = -1; acroSet = -1;
cosRise = -1; cosRise = -1;
cosSet = -1; cosSet = -1;
double bestDiffAcroRise = 12.0; double bestDiffAcroRise = 12.0;
double bestDiffAcroSet = 12.0; double bestDiffAcroSet = 12.0;
skipping to change at line 1099 skipping to change at line 1169
success = true; success = true;
hourDiffAcroRise = toUnsignedRA(objectRA[i] - object H0[i]); hourDiffAcroRise = toUnsignedRA(objectRA[i] - object H0[i]);
hourDiffCosRise = hourDiffAcroRise-sunSidT[3][i]; hourDiffCosRise = hourDiffAcroRise-sunSidT[3][i];
hourDiffAcroRise -= sunSidT[2][i]; hourDiffAcroRise -= sunSidT[2][i];
hourDiffAcroSet = toUnsignedRA(objectRA[i] + objectH 0[i]); hourDiffAcroSet = toUnsignedRA(objectRA[i] + objectH 0[i]);
hourCosDiffSet = hourDiffAcroSet - sunSidT[2][i]; hourCosDiffSet = hourDiffAcroSet - sunSidT[2][i];
hourDiffAcroSet -= sunSidT[3][i]; hourDiffAcroSet -= sunSidT[3][i];
// Acronychal rise/set: // Acronychal rise/set:
if (std::abs(hourDiffAcroRise) < bestDiffAcroRise) if (qAbs(hourDiffAcroRise) < bestDiffAcroRise)
{ {
bestDiffAcroRise = std::abs(hourDiffAcroRise ); bestDiffAcroRise = qAbs(hourDiffAcroRise);
acroRise = i; acroRise = i;
}; };
if (std::abs(hourDiffAcroSet) < bestDiffAcroSet) if (qAbs(hourDiffAcroSet) < bestDiffAcroSet)
{ {
bestDiffAcroSet = std::abs(hourDiffAcroSet); bestDiffAcroSet = qAbs(hourDiffAcroSet);
acroSet = i; acroSet = i;
}; };
// Cosmical Rise/Set: // Cosmical Rise/Set:
if (std::abs(hourDiffCosRise) < bestDiffCosRise) if (qAbs(hourDiffCosRise) < bestDiffCosRise)
{ {
bestDiffCosRise = std::abs(hourDiffCosRise); bestDiffCosRise = qAbs(hourDiffCosRise);
cosRise = i; cosRise = i;
}; };
if (std::abs(hourCosDiffSet) < bestDiffCosSet) if (qAbs(hourCosDiffSet) < bestDiffCosSet)
{ {
bestDiffCosSet = std::abs(hourCosDiffSet); bestDiffCosSet = qAbs(hourCosDiffSet);
cosSet = i; cosSet = i;
}; };
}; };
}; };
acroRise *= (bestDiffAcroRise > 0.083)?-1:1; // Check that differenc e is lower than 5 minutes. acroRise *= (bestDiffAcroRise > 0.083)?-1:1; // Check that differenc e is lower than 5 minutes.
acroSet *= (bestDiffAcroSet > 0.083)?-1:1; // Check that difference is lower than 5 minutes. acroSet *= (bestDiffAcroSet > 0.083)?-1:1; // Check that difference is lower than 5 minutes.
cosRise *= (bestDiffCosRise > 0.083)?-1:1; // Check that difference is lower than 5 minutes. cosRise *= (bestDiffCosRise > 0.083)?-1:1; // Check that difference is lower than 5 minutes.
cosSet *= (bestDiffCosSet > 0.083)?-1:1; // Check that difference is lower than 5 minutes. cosSet *= (bestDiffCosSet > 0.083)?-1:1; // Check that difference is lower than 5 minutes.
int result = (acroRise>0 || acroSet>0) ? 1 : 0; int result = (acroRise>0 || acroSet>0) ? 1 : 0;
skipping to change at line 1280 skipping to change at line 1350
const int NUM_ITER = 100; const int NUM_ITER = 100;
int i; int i;
double hHoriz, ra, dec, raSun, decSun, tempH, tempJd, tempEphH, curS idT, eclLon; double hHoriz, ra, dec, raSun, decSun, tempH, tempJd, tempEphH, curS idT, eclLon;
//Vec3d Observer; //Vec3d Observer;
hHoriz = calculateHourAngle(mylat, refractedHorizonAlt, selDec); hHoriz = calculateHourAngle(mylat, refractedHorizonAlt, selDec);
bool raises = hHoriz > 0.0; bool raises = hHoriz > 0.0;
// Only recompute ephemeris from second to second (at least) // Only recompute ephemeris from second to second (at least)
// or if the source has changed (i.e., Sun <-> Moon). This saves resources: // or if the source has changed (i.e., Sun <-> Moon). This saves resources:
if (std::abs(myJD-lastJDMoon)>JDsec || lastType!=bodyType || souChan ged) if (qAbs(myJD-lastJDMoon)>JDsec || lastType!=bodyType || souChanged)
{ {
// qDebug() << q_("%1 %2 %3 %4").arg(Kind).arg(LastObject) .arg(myJD,0,'f',5).arg(lastJDMoon,0,'f',5); // qDebug() << q_("%1 %2 %3 %4").arg(Kind).arg(LastObject) .arg(myJD,0,'f',5).arg(lastJDMoon,0,'f',5);
lastType = bodyType; lastType = bodyType;
myEarth->computePosition(myJD); myEarth->computePosition(myJD);
myEarth->computeTransMatrix(myJD); myEarth->computeTransMatrix(myJD);
Vec3d earthPos = myEarth->getHeliocentricEclipticPos(); Vec3d earthPos = myEarth->getHeliocentricEclipticPos();
skipping to change at line 1368 skipping to change at line 1438
Hcurr = toUnsignedRA(SidT-ra); Hcurr = toUnsignedRA(SidT-ra);
Hcurr -= (hasRisen)?0.0:24.; Hcurr -= (hasRisen)?0.0:24.;
Hcurr -= (Hcurr>12.)?24.0:0.0; Hcurr -= (Hcurr>12.)?24.0:0.0;
// H at horizon for mod. coordinates: // H at horizon for mod. coordinates:
hHoriz = calculateHourAngle(mylat,refractedH orizonAlt,dec); hHoriz = calculateHourAngle(mylat,refractedH orizonAlt,dec);
// Compute eph. times for mod. coordinates: // Compute eph. times for mod. coordinates:
tempH = (-hHoriz-Hcurr)*TFrac; tempH = (-hHoriz-Hcurr)*TFrac;
if (hasRisen==false) tempH += (tempH<0.0)?24 .0:0.0; if (hasRisen==false) tempH += (tempH<0.0)?24 .0:0.0;
// Check convergence: // Check convergence:
if (std::abs(tempH-tempEphH)<JDsec) break; if (qAbs(tempH-tempEphH)<JDsec) break;
// Update rise-time estimate: // Update rise-time estimate:
tempEphH = tempH; tempEphH = tempH;
MoonRise = myJD + (tempEphH/24.); MoonRise = myJD + (tempEphH/24.);
}; };
// Set time: // Set time:
tempEphH = MoonSet; tempEphH = MoonSet;
MoonSet = myJD + (MoonSet/24.); MoonSet = myJD + (MoonSet/24.);
for (i=0; i<NUM_ITER; i++) for (i=0; i<NUM_ITER; i++)
{ {
skipping to change at line 1403 skipping to change at line 1473
Hcurr = toUnsignedRA(SidT-ra); Hcurr = toUnsignedRA(SidT-ra);
Hcurr -= (hasRisen)?24.:0.; Hcurr -= (hasRisen)?24.:0.;
Hcurr += (Hcurr<-12.)?24.0:0.0; Hcurr += (Hcurr<-12.)?24.0:0.0;
// H at horizon for mod. coordinates: // H at horizon for mod. coordinates:
hHoriz = calculateHourAngle(mylat, refracted HorizonAlt, dec); hHoriz = calculateHourAngle(mylat, refracted HorizonAlt, dec);
// Compute eph. times for mod. coordinates: // Compute eph. times for mod. coordinates:
tempH = (hHoriz-Hcurr)*TFrac; tempH = (hHoriz-Hcurr)*TFrac;
if (!hasRisen) if (!hasRisen)
tempH -= (tempH>0.0)?24.0:0.0; tempH -= (tempH>0.0)?24.0:0.0;
// Check convergence: // Check convergence:
if (std::abs(tempH-tempEphH)<JDsec) if (qAbs(tempH-tempEphH)<JDsec)
break; break;
// Update set-time estimate: // Update set-time estimate:
tempEphH = tempH; tempEphH = tempH;
MoonSet = myJD + (tempEphH/24.); MoonSet = myJD + (tempEphH/24.);
}; };
} }
else // Comes from if(raises) else // Comes from if(raises)
{ {
MoonSet = -1.0; MoonSet = -1.0;
MoonRise = -1.0; MoonRise = -1.0;
skipping to change at line 1443 skipping to change at line 1513
if (bodyType==1) {ra = raSun; dec = decSun;}; if (bodyType==1) {ra = raSun; dec = decSun;};
// Current hour angle at mod. coordinates: // Current hour angle at mod. coordinates:
Hcurr = toUnsignedRA(SidT-ra); Hcurr = toUnsignedRA(SidT-ra);
Hcurr += (LocPos[1]<0.0)?24.0:-24.0; Hcurr += (LocPos[1]<0.0)?24.0:-24.0;
Hcurr -= (Hcurr>12.)?24.0:0.0; Hcurr -= (Hcurr>12.)?24.0:0.0;
// Compute eph. times for mod. coordinates: // Compute eph. times for mod. coordinates:
tempH = -Hcurr*TFrac; tempH = -Hcurr*TFrac;
// Check convergence: // Check convergence:
if (std::abs(tempH-tempEphH)<JDsec) break; if (qAbs(tempH-tempEphH)<JDsec) break;
tempEphH = tempH; tempEphH = tempH;
MoonCulm = myJD + (tempEphH/24.); MoonCulm = myJD + (tempEphH/24.);
culmAlt = std::abs(mylat-dec); // 90 - altitude at t ransit. culmAlt = qAbs(mylat-dec); // 90 - altitude at trans it.
}; };
// qDebug() << q_("%1").arg(MoonCulm,0,'f',5); // qDebug() << q_("%1").arg(MoonCulm,0,'f',5);
lastJDMoon = myJD; lastJDMoon = myJD;
}; // Comes from if (std::abs(myJD-lastJDMoon)>JDsec || LastObject!= Kind) }; // Comes from if (qAbs(myJD-lastJDMoon)>JDsec || LastObject!=Kind )
// Find out the days of Full Moon: // Find out the days of Full Moon:
if (bodyType==2 && show_FullMoon) // || show_SuperMoon)) if (bodyType==2 && show_FullMoon) // || show_SuperMoon))
{ {
// Only estimate date of Full Moon if we have changed Lunar month: // Only estimate date of Full Moon if we have changed Lunar month:
if (myJD > nextFullMoon || myJD < prevFullMoon) if (myJD > nextFullMoon || myJD < prevFullMoon)
{ {
// Estimate the nearest (in time) Full Moon: // Estimate the nearest (in time) Full Moon:
skipping to change at line 1510 skipping to change at line 1580
Sec2 = Phase1; Sec2 = Phase1;
Temp2 = eclLon; Temp2 = eclLon;
} else { } else {
Sec1 = Phase1; Sec1 = Phase1;
Temp1 = eclLon; Temp1 = eclLon;
}; };
// qDebug() << QString("%1 %2 %3 %4 "). arg(Sec1).arg(Sec2).arg(Temp1).arg(Temp2); // qDebug() << QString("%1 %2 %3 %4 "). arg(Sec1).arg(Sec2).arg(Temp1).arg(Temp2);
if (std::abs(Sec2-Sec1) < 10.*dT) / / 1 minute accuracy; convergence. if (qAbs(Sec2-Sec1) < 10.*dT) // 1 minute accuracy; convergence.
{ {
TempFullMoon = (Sec1+Sec2)/2 .; TempFullMoon = (Sec1+Sec2)/2 .;
// qDebug() << QString("%1%2 ") .arg(TempFullMoon); // qDebug() << QString("%1%2 ") .arg(TempFullMoon);
break; break;
}; };
}; };
if (TempFullMoon > myJD) if (TempFullMoon > myJD)
{ {
 End of changes. 37 change blocks. 
39 lines changed or deleted 118 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/