MinorPlanet.cpp   MinorPlanet.cpp 
skipping to change at line 26 skipping to change at line 26
* 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "MinorPlanet.hpp" #include "MinorPlanet.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelTexture.hpp"
#include "StelTextureMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelFileMgr.hpp"
#include <QRegExp> #include <QRegExp>
#include <QDebug> #include <QDebug>
MinorPlanet::MinorPlanet(const QString& englishName, MinorPlanet::MinorPlanet(const QString& englishName,
int flagLighting, int flagLighting,
double radius, double radius,
double oblateness, double oblateness,
Vec3f color, Vec3f color,
float albedo, float albedo,
const QString& atexMapName, const QString& atexMapName,
posFuncType coordFunc, posFuncType coordFunc,
void* auserDataPtr, void* auserDataPtr,
OsculatingFunctType *oscula OsculatingFunctType *osculatingFunc,
tingFunc, bool acloseOrbit,
bool acloseOrbit, bool hidden,
bool hidden, const QString &pType)
const QString& pType) : Planet (englishName,
: Planet (englishName, flagLighting,
flagLighti radius,
ng, oblateness,
radius, color,
oblateness albedo,
, atexMapName,
color, "",
albedo, coordFunc,
atexMapNam auserDataPtr,
e, osculatingFunc,
coordFunc, acloseOrbit,
auserDataP hidden,
tr, false, //No atmosphere
osculating true, //Halo
Func, pType)
acloseOrbi
t,
hidden,
false, //N
o atmosphere
pType)
{ {
texMapName = atexMapName; texMapName = atexMapName;
lastOrbitJD =0; lastOrbitJD =0;
deltaJD = StelCore::JD_SECOND; deltaJD = StelCore::JD_SECOND;
orbitCached = 0; orbitCached = 0;
closeOrbit = acloseOrbit; closeOrbit = acloseOrbit;
semiMajorAxis = 0.;
eclipticPos=Vec3d(0.,0.,0.); eclipticPos=Vec3d(0.,0.,0.);
rotLocalToParent = Mat4d::identity(); rotLocalToParent = Mat4d::identity();
texMap = StelApp::getInstance().getTextureManager().createTextureThr ead(StelFileMgr::getInstallationDir()+"/textures/"+texMapName, StelTexture: :StelTextureParams(true, GL_LINEAR, GL_REPEAT));
//MinorPlanet specific members //MinorPlanet specific members
minorPlanetNumber = 0; minorPlanetNumber = 0;
absoluteMagnitude = 0; absoluteMagnitude = 0;
slopeParameter = -1;//== uninitialized: used in getVMagnitude() slopeParameter = -1;//== uninitialized: used in getVMagnitude()
//TODO: Fix the name //TODO: Fix the name
// - Detect numeric prefix and set number if any // - Detect numeric prefix and set number if any
// - detect provisional designation // - detect provisional designation
// - create the HTML name // - create the HTML name
skipping to change at line 206 skipping to change at line 213
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 (!nameIsProvisionalDesignation && !provisionalDesignation Html.isEmpty()) if (!nameIsProvisionalDesignation && !provisionalDesignation Html.isEmpty())
{ {
oss << QString(q_("Provisional designation: %1")).ar g(provisionalDesignationHtml); oss << QString(q_("Provisional designation: %1")).ar g(provisionalDesignationHtml);
oss << "<br>"; oss << "<br>";
} }
} }
if (flags&Extra1) if (flags&ObjectType)
{ {
if (pType.length()>0) if (pType.length()>0)
oss << q_("Type: <b>%1</b>").arg(q_(pType)) << "<br />"; oss << q_("Type: <b>%1</b>").arg(q_(pType)) << "<br />";
} }
if (flags&Magnitude) if (flags&Magnitude)
{ {
if (core->getSkyDrawer()->getFlagHasAtmosphere()) if (core->getSkyDrawer()->getFlagHasAtmosphere())
oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)"). oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)").
arg(QString::number(getVMagnitude(core, false), 'f', 2), arg(QString::number(getVMagnitude(core), 'f', 2),
QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>"; QString::number(getVMagnitudeWithExtinction(core), 'f', 2)) << "<br>";
else else
oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core, fa lse), 0, 'f', 2) << "<br>"; oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0 , 'f', 2) << "<br>";
} }
if (flags&AbsoluteMagnitude) if (flags&AbsoluteMagnitude)
{ {
//TODO: Make sure absolute magnitude is a sane value //TODO: Make sure absolute magnitude is a sane value
//If the H-G system is not used, use the default radius/albe do mechanism //If the H-G system is not used, use the default radius/albe do mechanism
if (slopeParameter < 0) if (slopeParameter < 0)
{ {
oss << q_("Absolute Magnitude: %1").arg(getVMagnitud e(core, false) - 5. * (std::log10(getJ2000EquatorialPos(core).length()*AU/P ARSEC)-1.), 0, 'f', 2) << "<br>"; oss << q_("Absolute Magnitude: %1").arg(getVMagnitud e(core) - 5. * (std::log10(getJ2000EquatorialPos(core).length()*AU/PARSEC)- 1.), 0, 'f', 2) << "<br>";
} }
else else
{ {
oss << q_("Absolute Magnitude: %1").arg(absoluteMagn itude, 0, 'f', 2) << "<br>"; oss << q_("Absolute Magnitude: %1").arg(absoluteMagn itude, 0, 'f', 2) << "<br>";
} }
} }
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
if (flags&Distance) if (flags&Distance)
{ {
double distanceAu = getJ2000EquatorialPos(core).length(); double distanceAu = getJ2000EquatorialPos(core).length();
double distanceKm = AU * distanceAu;
if (distanceAu < 0.1) if (distanceAu < 0.1)
{ {
double distanceKm = AU * distanceAu;
// xgettext:no-c-format // xgettext:no-c-format
oss << QString(q_("Distance: %1AU (%2 km)")) oss << QString(q_("Distance: %1AU (%2 km)"))
.arg(distanceAu, 0, 'f', 8) .arg(distanceAu, 0, 'f', 6)
.arg(distanceKm, 0, 'f', 0); .arg(distanceKm, 0, 'f', 3);
} }
else else
{ {
// xgettext:no-c-format // xgettext:no-c-format
oss << q_("Distance: %1AU").arg(distanceAu, 0, 'f', oss << QString(q_("Distance: %1AU (%2 Mio km)"))
8); .arg(distanceAu, 0, 'f', 3)
.arg(distanceKm / 1.0e6, 0, 'f', 3);
} }
oss << "<br>"; oss << "<br>";
} }
if (flags&Size) if (flags&Size)
oss << q_("Apparent diameter: %1").arg(StelUtils::radToDmsSt r(2.*getAngularSize(core)*M_PI/180., true)) << "<br>"; oss << q_("Apparent diameter: %1").arg(StelUtils::radToDmsSt r(2.*getAngularSize(core)*M_PI/180., true)) << "<br>";
// If semi-major axis not zero then calculate and display orbital pe riod for asteroid in days // If semi-major axis not zero then calculate and display orbital pe riod for asteroid in days
double siderealPeriod = getSiderealPeriod(); double siderealPeriod = getSiderealPeriod();
if ((flags&Extra1) && (siderealPeriod>0)) if ((flags&Extra) && (siderealPeriod>0))
{ {
// TRANSLATORS: Sidereal (orbital) period for solar system b odies in days and in Julian years (symbol: a) // TRANSLATORS: Sidereal (orbital) period for solar system b odies in days and in Julian years (symbol: a)
oss << q_("Sidereal period: %1 days (%2 a)").arg(QString::nu mber(siderealPeriod, 'f', 2)).arg(QString::number(siderealPeriod/365.25, 'f ', 3)) << "<br>"; oss << q_("Sidereal period: %1 days (%2 a)").arg(QString::nu mber(siderealPeriod, 'f', 2)).arg(QString::number(siderealPeriod/365.25, 'f ', 3)) << "<br>";
} }
//This doesn't work, even if setOpenExternalLinks(true) is used in I nfoPanel //This doesn't work, even if setOpenExternalLinks(true) is used in I nfoPanel
/* /*
if (flags&Extra1) if (flags&Extra)
oss << QString("<br><a href=\"http://ssd.jpl.nasa.gov/sbdb.c gi?sstr=%1\">JPL Small-Body Database Browser</a>").arg( (minorPlanetNumber) ? QString::number(minorPlanetNumber) : englishName ); oss << QString("<br><a href=\"http://ssd.jpl.nasa.gov/sbdb.c gi?sstr=%1\">JPL Small-Body Database Browser</a>").arg( (minorPlanetNumber) ? QString::number(minorPlanetNumber) : englishName );
*/ */
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
double MinorPlanet::getSiderealPeriod() const double MinorPlanet::getSiderealPeriod() const
{ {
double period; double period;
if (semiMajorAxis>0) if (semiMajorAxis>0)
period = StelUtils::calculateSiderealPeriod(semiMajorAxis); period = StelUtils::calculateSiderealPeriod(semiMajorAxis);
else else
period = 0; period = 0;
return period; return period;
} }
float MinorPlanet::getVMagnitude(const StelCore* core, bool withExtinction) const float MinorPlanet::getVMagnitude(const StelCore* core) const
{ {
float extinctionMag=0.0; // track magnitude loss
if (withExtinction)
{
Vec3d altAz=getAltAzPosApparent(core);
altAz.normalize();
core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinc
tionMag);
}
//If the H-G system is not used, use the default radius/albedo mecha nism //If the H-G system is not used, use the default radius/albedo mecha nism
if (slopeParameter < 0) if (slopeParameter < 0)
{ {
return Planet::getVMagnitude(core, withExtinction); return Planet::getVMagnitude(core);
} }
//Calculate phase angle //Calculate phase angle
//(Code copied from Planet::getVMagnitude()) //(Code copied from Planet::getVMagnitude())
//(LOL, this is actually vector subtraction + the cosine theorem :)) //(LOL, this is actually vector subtraction + the cosine theorem :))
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();
skipping to change at line 325 skipping to change at line 326
double phaseAngle = std::acos(cos_chi); double phaseAngle = std::acos(cos_chi);
//Calculate reduced magnitude (magnitude without the influence of di stance) //Calculate reduced magnitude (magnitude without the influence of di stance)
//Source of the formulae: http://www.britastro.org/asteroids/dymock4 .pdf //Source of the formulae: http://www.britastro.org/asteroids/dymock4 .pdf
const double phi1 = std::exp(-3.33 * std::pow(std::tan(phaseAngle/2) , 0.63)); const double phi1 = std::exp(-3.33 * std::pow(std::tan(phaseAngle/2) , 0.63));
const double phi2 = std::exp(-1.87 * std::pow(std::tan(phaseAngle/2) , 1.22)); const double phi2 = std::exp(-1.87 * std::pow(std::tan(phaseAngle/2) , 1.22));
double reducedMagnitude = absoluteMagnitude - 2.5 * std::log10( (1 - slopeParameter) * phi1 + slopeParameter * phi2 ); double reducedMagnitude = absoluteMagnitude - 2.5 * std::log10( (1 - slopeParameter) * phi1 + slopeParameter * phi2 );
//Calculate apparent magnitude //Calculate apparent magnitude
//TODO: See if you can "collapse" some calculations //TODO: See if you can "collapse" some calculations
// -- GZ: NO! This is also in Meeus, Astr.Alg. 1998, p.231 and autho
ritative by IAU commission 20, New Delhi November 1985.
// (you can collapse and leave away the reducedMagnitude varab
le, but this is cosmetic)
double apparentMagnitude = reducedMagnitude + 5 * std::log10(std::sq rt(planetRq * observerPlanetRq)); double apparentMagnitude = reducedMagnitude + 5 * std::log10(std::sq rt(planetRq * observerPlanetRq));
return apparentMagnitude+extinctionMag; return apparentMagnitude;
} }
void MinorPlanet::translateName(StelTranslator &translator) void MinorPlanet::translateName(const StelTranslator &translator)
{ {
nameI18 = translator.qtranslate(properName); nameI18 = translator.qtranslate(properName);
if (englishName.endsWith('*')) if (englishName.endsWith('*'))
{ {
nameI18.append('*'); nameI18.append('*');
} }
} }
QString MinorPlanet::renderProvisionalDesignationinHtml(QString plainTextNa me) QString MinorPlanet::renderProvisionalDesignationinHtml(QString plainTextNa me)
{ {
 End of changes. 21 change blocks. 
61 lines changed or deleted 56 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/