Planet.cpp   Planet.cpp 
skipping to change at line 17 skipping to change at line 17
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include <iomanip> #include <iomanip>
#include <QTextStream> #include <QTextStream>
#include <QString> #include <QString>
#include <QDebug> #include <QDebug>
#include <QVarLengthArray> #include <QVarLengthArray>
#include "StelApp.hpp" #include "StelApp.hpp"
skipping to change at line 42 skipping to change at line 42
#include "Planet.hpp" #include "Planet.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "sideral_time.h" #include "sideral_time.h"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelUtils.hpp"
Vec3f Planet::labelColor = Vec3f(0.4,0.4,0.8); Vec3f Planet::labelColor = Vec3f(0.4,0.4,0.8);
Vec3f Planet::orbitColor = Vec3f(1,0.6,1); Vec3f Planet::orbitColor = Vec3f(1,0.6,1);
StelTextureSP Planet::hintCircleTex; StelTextureSP Planet::hintCircleTex;
StelTextureSP Planet::texEarthShadow; StelTextureSP Planet::texEarthShadow;
Planet::Planet(const QString& englishName, Planet::Planet(const QString& englishName,
int flagLighting, int flagLighting,
double radius, double radius,
double oblateness, double oblateness,
skipping to change at line 120 skipping to change at line 121
{ {
oss << "<h2>" << q_(englishName); // UI translation can dif fer from sky translation oss << "<h2>" << q_(englishName); // UI translation can dif fer from sky translation
oss.setRealNumberNotation(QTextStream::FixedNotation); oss.setRealNumberNotation(QTextStream::FixedNotation);
oss.setRealNumberPrecision(1); oss.setRealNumberPrecision(1);
if (sphereScale != 1.f) if (sphereScale != 1.f)
oss << QString::fromUtf8(" (\xC3\x97") << sphereScal e << ")"; oss << QString::fromUtf8(" (\xC3\x97") << sphereScal e << ")";
oss << "</h2>"; oss << "</h2>";
} }
if (flags&Magnitude) if (flags&Magnitude)
oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0 {
, 'f', 2) << "<br>"; if (core->getSkyDrawer()->getFlagHasAtmosphere())
oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>
)").arg(QString::number(getVMagnitude(core, false), 'f', 2),
QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>";
else
oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core
, false), 0, 'f', 2) << "<br>";
}
if (flags&AbsoluteMagnitude) if (flags&AbsoluteMagnitude)
oss << q_("Absolute Magnitude: %1").arg(getVMagnitude(core)- 5.*(std::log10(getJ2000EquatorialPos(core).length()*AU/PARSEC)-1.), 0, 'f', 2) << "<br>"; oss << q_("Absolute Magnitude: %1").arg(getVMagnitude(core, false)-5.*(std::log10(getJ2000EquatorialPos(core).length()*AU/PARSEC)-1.), 0, 'f', 2) << "<br>";
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
if ((flags&Extra2) && (core->getCurrentLocation().planetName=="Earth ")) if ((flags&Extra2) && (core->getCurrentLocation().planetName=="Earth "))
{ {
//static SolarSystem *ssystem=GETSTELMODULE(SolarSystem); //static SolarSystem *ssystem=GETSTELMODULE(SolarSystem);
//double ecl= -(ssystem->getEarth()->getRotObliquity()); // BUG DETECTED! Earth's obliquity is apparently reported constant. //double ecl= -(ssystem->getEarth()->getRotObliquity()); // BUG DETECTED! Earth's obliquity is apparently reported constant.
double ra_equ, dec_equ, lambda, beta; double ra_equ, dec_equ, lambda, beta;
double ecl= get_mean_ecliptical_obliquity(core->getJDay()) * M_PI/180.0; double ecl= get_mean_ecliptical_obliquity(core->getJDay()) * M_PI/180.0;
StelUtils::rectToSphe(&ra_equ,&dec_equ,getEquinoxEquatorialP os(core)); StelUtils::rectToSphe(&ra_equ,&dec_equ,getEquinoxEquatorialP os(core));
StelUtils::ctRadec2Ecl(ra_equ, dec_equ, ecl, &lambda, &beta) ; StelUtils::ctRadec2Ecl(ra_equ, dec_equ, ecl, &lambda, &beta) ;
if (lambda<0) lambda+=2.0*M_PI; if (lambda<0) lambda+=2.0*M_PI;
oss << q_("Ecliptic Geocentric (of date): %1/%2").arg(StelUt ils::radToDmsStr(lambda, true), StelUtils::radToDmsStr(beta, true)) << "<br >"; oss << q_("Ecliptic Geocentric (of date): %1/%2").arg(StelUt ils::radToDmsStr(lambda, true), StelUtils::radToDmsStr(beta, true)) << "<br >";
oss << q_("Obliquity (of date): %1").arg(StelUtils::radToDms Str(ecl, true)) << "<br>"; oss << q_("Obliquity (of date): %1").arg(StelUtils::radToDms Str(ecl, true)) << "<br>";
} }
if (flags&Distance) if (flags&Distance)
{ {
// xgettext:no-c-format double distanceAu = getJ2000EquatorialPos(core).length();
oss << q_("Distance: %1AU").arg(getJ2000EquatorialPos(core). if (distanceAu < 0.1)
length(), 0, 'f', 8) << "<br>"; {
double distanceKm = AU * distanceAu;
// xgettext:no-c-format
oss << QString(q_("Distance: %1AU (%2 km)"))
.arg(distanceAu, 0, 'f', 8)
.arg(distanceKm, 0, 'f', 0);
}
else
{
// xgettext:no-c-format
oss << q_("Distance: %1AU").arg(distanceAu, 0, 'f',
8);
}
oss << "<br>";
} }
if (flags&Size) if (flags&Size)
oss << q_("Apparent diameter: %1").arg(StelUtils::radToDmsSt r(2.*getAngularSize(core)*M_PI/180., true)); oss << q_("Apparent diameter: %1").arg(StelUtils::radToDmsSt r(2.*getAngularSize(core)*M_PI/180., true));
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
skipping to change at line 174 skipping to change at line 193
oss << QString::fromUtf8(" (\xC3\x97") << sphereScale << ")" ; oss << QString::fromUtf8(" (\xC3\x97") << sphereScale << ")" ;
} }
return str; return str;
} }
float Planet::getSelectPriority(const StelCore* core) const float Planet::getSelectPriority(const StelCore* core) const
{ {
if( ((SolarSystem*)StelApp::getInstance().getModuleMgr().getModule(" SolarSystem"))->getFlagHints() ) if( ((SolarSystem*)StelApp::getInstance().getModuleMgr().getModule(" SolarSystem"))->getFlagHints() )
{ {
// easy to select, especially pluto // easy to select, especially pluto
return getVMagnitude(core)-15.f; return getVMagnitude(core, false)-15.f;
} }
else else
{ {
return getVMagnitude(core) - 8.f; return getVMagnitude(core, false) - 8.f;
} }
} }
Vec3f Planet::getInfoColor(void) const Vec3f Planet::getInfoColor(void) const
{ {
return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.8, 0.2, 0.4) : ((SolarSystem*)StelApp::getInstance().getModuleMgr().getModule("Sol arSystem"))->getLabelsColor(); return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.8, 0.2, 0.4) : ((SolarSystem*)StelApp::getInstance().getModuleMgr().getModule("Sol arSystem"))->getLabelsColor();
} }
double Planet::getCloseViewFov(const StelCore* core) const double Planet::getCloseViewFov(const StelCore* core) const
{ {
skipping to change at line 464 skipping to change at line 483
double Planet::getPhase(const Vec3d& obsPos) const double Planet::getPhase(const Vec3d& obsPos) const
{ {
const double observerRq = obsPos.lengthSquared(); const double observerRq = obsPos.lengthSquared();
const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos();
const double planetRq = planetHelioPos.lengthSquared(); const double planetRq = planetHelioPos.lengthSquared();
const double observerPlanetRq = (obsPos - planetHelioPos).lengthSqua red(); const double observerPlanetRq = (obsPos - planetHelioPos).lengthSqua red();
return std::acos(observerPlanetRq + planetRq - observerRq)/(2.0*sqrt (observerPlanetRq*planetRq)); return std::acos(observerPlanetRq + planetRq - observerRq)/(2.0*sqrt (observerPlanetRq*planetRq));
} }
// Computation of the visual magnitude (V band) of the planet. // Computation of the visual magnitude (V band) of the planet.
float Planet::getVMagnitude(const StelCore* core) const float Planet::getVMagnitude(const StelCore* core, bool withExtinction) cons t
{ {
float extinctionMag=0.0; // track magnitude loss
if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere())
{
Vec3d altAz=getAltAzPosApparent(core);
altAz.normalize();
core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinc
tionMag);
}
if (parent == 0) if (parent == 0)
{ {
// sun, compute the apparent magnitude for the absolute mag (4.83) and observer's distance // sun, compute the apparent magnitude for the absolute mag (4.83) and observer's distance
const double distParsec = std::sqrt(core->getObserverHelioce ntricEclipticPos().lengthSquared())*AU/PARSEC; const double distParsec = std::sqrt(core->getObserverHelioce ntricEclipticPos().lengthSquared())*AU/PARSEC;
return 4.83 + 5.*(std::log10(distParsec)-1.); return 4.83 + 5.*(std::log10(distParsec)-1.) + extinctionMag ;
} }
// Compute the angular phase // Compute the angular phase
const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipti cPos(); const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipti cPos();
const double observerRq = observerHelioPos.lengthSquared(); const double observerRq = observerHelioPos.lengthSquared();
const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos();
const double planetRq = planetHelioPos.lengthSquared(); const double planetRq = planetHelioPos.lengthSquared();
const double observerPlanetRq = (observerHelioPos - planetHelioPos). lengthSquared(); const double observerPlanetRq = (observerHelioPos - planetHelioPos). lengthSquared();
const double cos_chi = (observerPlanetRq + planetRq - observerRq)/(2 .0*sqrt(observerPlanetRq*planetRq)); const double cos_chi = (observerPlanetRq + planetRq - observerRq)/(2 .0*sqrt(observerPlanetRq*planetRq));
double phase = std::acos(cos_chi); double phase = std::acos(cos_chi);
skipping to change at line 515 skipping to change at line 542
{ {
// The satellite is partly inside the inner shadow, // The satellite is partly inside the inner shadow,
// compute a fantasy value for the magnitude : // compute a fantasy value for the magnitude :
d /= radius; d /= radius;
shadowFactor = (0.5 - (std::asin(d)+d*std::s qrt(1.0-d*d))/M_PI); shadowFactor = (0.5 - (std::asin(d)+d*std::s qrt(1.0-d*d))/M_PI);
} }
} }
} }
// Use empirical formulae for main planets when seen from earth // Use empirical formulae for main planets when seen from earth
// Algorithm provided by Pere Planesas (Observatorio Astronomico Nac ional)
if (core->getCurrentLocation().planetName=="Earth") if (core->getCurrentLocation().planetName=="Earth")
{ {
phase*=180./M_PI; const double phaseDeg=phase*180./M_PI;
const double d = 5. * log10(sqrt(observerPlanetRq*planetRq)) ; const double d = 5. * log10(sqrt(observerPlanetRq*planetRq)) ;
double f1 = phase/100.; //double f1 = phaseDeg/100.;
/*
// Algorithm provided by Pere Planesas (Observatorio Astrono
mico Nacional)
if (englishName=="Mercury") if (englishName=="Mercury")
{ {
if ( phase > 150. ) f1 = 1.5; if ( phaseDeg > 150. ) f1 = 1.5;
return -0.36 + d + 3.8*f1 - 2.73*f1*f1 + 2*f1*f1*f1; return -0.36 + d + 3.8*f1 - 2.73*f1*f1 + 2*f1*f1*f1
+ extinctionMag;
} }
if (englishName=="Venus") if (englishName=="Venus")
return -4.29 + d + 0.09*f1 + 2.39*f1*f1 - 0.65*f1*f1 *f1; return -4.29 + d + 0.09*f1 + 2.39*f1*f1 - 0.65*f1*f1 *f1 + extinctionMag;
if (englishName=="Mars") if (englishName=="Mars")
return -1.52 + d + 0.016*phase; return -1.52 + d + 0.016*phaseDeg + extinctionMag;
if (englishName=="Jupiter") if (englishName=="Jupiter")
return -9.25 + d + 0.005*phase; return -9.25 + d + 0.005*phaseDeg + extinctionMag;
if (englishName=="Saturn") if (englishName=="Saturn")
{ {
// TODO re-add rings computation // TODO re-add rings computation
// double rings = -2.6*sinx + 1.25*sinx*sinx; // double rings = -2.6*sinx + 1.25*sinx*sinx;
return -8.88 + d + 0.044*phase;// + rings; return -8.88 + d + 0.044*phaseDeg + extinctionMag;// + rings;
} }
if (englishName=="Uranus") if (englishName=="Uranus")
return -7.19 + d + 0.0028*phase; return -7.19 + d + 0.0028*phaseDeg + extinctionMag;
if (englishName=="Neptune") if (englishName=="Neptune")
return -6.87 + d; return -6.87 + d + extinctionMag;
if (englishName=="Pluto") if (englishName=="Pluto")
return -1.01 + d + 0.041*phase; return -1.01 + d + 0.041*phaseDeg + extinctionMag;
*/
phase/=180./M_PI; // GZ: I prefer the values given by Meeus, Astronomical Algo
rithms (1992).
// There are two solutions:
// (1) G. Mller, based on visual observations 1877-91. [Expl
.Suppl.1961]
// (2) Astronomical Almanac 1984 and later. These give V (in
strumental) magnitudes.
// The structure is almost identical, just the numbers are d
ifferent!
// I activate (1) for now, because we want to simulate the e
ye's impression. (Esp. Venus!)
// (1)
if (englishName=="Mercury")
{
double ph50=phaseDeg-50.0;
return 1.16 + d + 0.02838*ph50 + 0.0001023*ph50*ph50
+ extinctionMag;
}
if (englishName=="Venus")
return -4.0 + d + 0.01322*phaseDeg + 0.0000004247*ph
aseDeg*phaseDeg*phaseDeg + extinctionMag;
if (englishName=="Mars")
return -1.3 + d + 0.01486*phaseDeg + extinctionMag;
if (englishName=="Jupiter")
return -8.93 + d + extinctionMag;
if (englishName=="Saturn")
{
// TODO re-add rings computation
// GZ: implemented from Meeus, Astr.Alg.1992
const double jd=core->getJDay();
const double T=(jd-2451545.0)/36525.0;
const double i=((0.000004*T-0.012998)*T+28.075216)*M
_PI/180.0;
const double Omega=((0.000412*T+1.394681)*T+169.5084
70)*M_PI/180.0;
static SolarSystem *ssystem=GETSTELMODULE(SolarSyste
m);
const Vec3d saturnEarth=getHeliocentricEclipticPos()
- ssystem->getEarth()->getHeliocentricEclipticPos();
double lambda=atan2(saturnEarth[1], saturnEarth[0]);
double beta=atan2(saturnEarth[2], sqrt(saturnEarth[0
]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1]));
const double sinB=sin(i)*cos(beta)*sin(lambda-Omega)
-cos(i)*sin(beta);
double rings = -2.6*fabs(sinB) + 1.25*sinB*sinB; //
sinx=sinB, saturnicentric latitude of earth. longish, see Meeus.
return -8.68 + d + 0.044*phaseDeg + rings + extincti
onMag;
}
if (englishName=="Uranus")
return -6.85 + d + extinctionMag;
if (englishName=="Neptune")
return -7.05 + d + extinctionMag;
if (englishName=="Pluto")
return -1.0 + d + extinctionMag;
/*
// (2)
if (englishName=="Mercury")
return 0.42 + d + .038*phaseDeg - 0.000273*phaseDeg*
phaseDeg + 0.000002*phaseDeg*phaseDeg*phaseDeg + extinctionMag;
if (englishName=="Venus")
return -4.40 + d + 0.0009*phaseDeg + 0.000239*phaseD
eg*phaseDeg - 0.00000065*phaseDeg*phaseDeg*phaseDeg + extinctionMag;
if (englishName=="Mars")
return -1.52 + d + 0.016*phaseDeg + extinctionMag;
if (englishName=="Jupiter")
return -9.40 + d + 0.005*phaseDeg + extinctionMag;
if (englishName=="Saturn")
{
// TODO re-add rings computation
// GZ: implemented from Meeus, Astr.Alg.1992
const double jd=core->getJDay();
const double T=(jd-2451545.0)/36525.0;
const double i=((0.000004*T-0.012998)*T+28.075216)*M
_PI/180.0;
const double Omega=((0.000412*T+1.394681)*T+169.5084
70)*M_PI/180.0;
static SolarSystem *ssystem=GETSTELMODULE(SolarSyste
m);
const Vec3d saturnEarth=getHeliocentricEclipticPos()
- ssystem->getEarth()->getHeliocentricEclipticPos();
double lambda=atan2(saturnEarth[1], saturnEarth[0]);
double beta=atan2(saturnEarth[2], sqrt(saturnEarth[0
]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1]));
const double sinB=sin(i)*cos(beta)*sin(lambda-Omega)
-cos(i)*sin(beta);
double rings = -2.6*fabs(sinB) + 1.25*sinB*sinB; //
sinx=sinB, saturnicentric latitude of earth. longish, see Meeus.
return -8.88 + d + 0.044*phaseDeg + rings + extincti
onMag;
}
if (englishName=="Uranus")
return -7.19f + d + extinctionMag;
if (englishName=="Neptune")
return -6.87f + d + extinctionMag;
if (englishName=="Pluto")
return -1.00f + d + extinctionMag;
*/
// TODO: decide which set of formulae is best?
} }
// This formula seems to give wrong results // This formula seems to give wrong results
const double p = (1.0 - phase/M_PI) * cos_chi + std::sqrt(1.0 - cos_ chi*cos_chi) / M_PI; const double p = (1.0 - phase/M_PI) * cos_chi + std::sqrt(1.0 - cos_ chi*cos_chi) / M_PI;
double F = 2.0 * albedo * radius * radius * p / (3.0*observerPlanetR q*planetRq) * shadowFactor; double F = 2.0 * albedo * radius * radius * p / (3.0*observerPlanetR q*planetRq) * shadowFactor;
return -26.73 - 2.5 * std::log10(F); return -26.73 - 2.5 * std::log10(F) + extinctionMag;
} }
double Planet::getAngularSize(const StelCore* core) const double Planet::getAngularSize(const StelCore* core) const
{ {
double rad = radius; double rad = radius;
if (rings) if (rings)
rad = rings->getSize(); rad = rings->getSize();
return std::atan2(rad*sphereScale,getJ2000EquatorialPos(core).length ()) * 180./M_PI; return std::atan2(rad*sphereScale,getJ2000EquatorialPos(core).length ()) * 180./M_PI;
} }
skipping to change at line 727 skipping to change at line 827
} }
// Draw the halo // Draw the halo
// Prepare openGL lighting parameters according to luminance // Prepare openGL lighting parameters according to luminance
float surfArcMin2 = getSpheroidAngularSize(core)*60; float surfArcMin2 = getSpheroidAngularSize(core)*60;
surfArcMin2 = surfArcMin2*surfArcMin2*M_PI; // the total illuminated area in arcmin^2 surfArcMin2 = surfArcMin2*surfArcMin2*M_PI; // the total illuminated area in arcmin^2
StelPainter sPainter(core->getProjection(StelCore::FrameJ2000)); StelPainter sPainter(core->getProjection(StelCore::FrameJ2000));
Vec3d tmp = getJ2000EquatorialPos(core); Vec3d tmp = getJ2000EquatorialPos(core);
core->getSkyDrawer()->postDrawSky3dModel(&sPainter, Vec3f(tmp[0], tm p[1], tmp[2]), surfArcMin2, getVMagnitude(core), color); core->getSkyDrawer()->postDrawSky3dModel(&sPainter, Vec3f(tmp[0], tm p[1], tmp[2]), surfArcMin2, getVMagnitude(core, true), color);
} }
void Planet::drawSphere(StelPainter* painter, float screenSz) void Planet::drawSphere(StelPainter* painter, float screenSz)
{ {
if (texMap) if (texMap)
{ {
// For lazy loading, return if texture not yet loaded // For lazy loading, return if texture not yet loaded
if (!texMap->bind()) if (!texMap->bind())
return; return;
} }
 End of changes. 25 change blocks. 
29 lines changed or deleted 159 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/