MinorPlanet.cpp   MinorPlanet.cpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2002 Fabien Chereau (some old code from the Planet class) * Copyright (C) 2002 Fabien Chereau (some old code from the Planet class)
* Copyright (C) 2010 Bogdan Marinov * Copyright (C) 2010 Bogdan Marinov
* Copyright (C) 2013-14 Georg Zotti (accuracy&speedup)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* 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.
skipping to change at line 47 skipping to change at line 48
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 *osculatingFunc, OsculatingFunctType *osculatingFunc,
bool acloseOrbit, bool acloseOrbit,
bool hidden, bool hidden,
const QString &pType) const QString &pTypeStr)
: Planet (englishName, : Planet (englishName,
flagLighting, flagLighting,
radius, radius,
oblateness, oblateness,
color, color,
albedo, albedo,
atexMapName, atexMapName,
"", "",
coordFunc, coordFunc,
auserDataPtr, auserDataPtr,
osculatingFunc, osculatingFunc,
acloseOrbit, acloseOrbit,
hidden, hidden,
false, //No atmosphere false, //No atmosphere
true, //Halo true, //Halo
pType) pTypeStr)
{ {
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.; semiMajorAxis = 0.;
eclipticPos=Vec3d(0.,0.,0.); eclipticPos=Vec3d(0.,0.,0.);
rotLocalToParent = Mat4d::identity(); rotLocalToParent = Mat4d::identity();
skipping to change at line 144 skipping to change at line 145
} }
MinorPlanet::~MinorPlanet() MinorPlanet::~MinorPlanet()
{ {
//Do nothing for the moment //Do nothing for the moment
} }
void MinorPlanet::setSemiMajorAxis(double value) void MinorPlanet::setSemiMajorAxis(double value)
{ {
semiMajorAxis = value; semiMajorAxis = value;
// GZ: patched for 2012DA14 and other NEA rendez-vous: // GZ: in case we have very many asteroids, this helps improving spe
if (semiMajorAxis < 1.666) ed usually without sacrificing accuracy:
{ deltaJD = 2.0*semiMajorAxis*StelCore::JD_SECOND;
deltaJD = 0.1*StelCore::JD_SECOND;
}
if (semiMajorAxis < 1.25)
{
deltaJD = 0.001*StelCore::JD_SECOND;
}
} }
void MinorPlanet::setMinorPlanetNumber(int number) void MinorPlanet::setMinorPlanetNumber(int number)
{ {
if (minorPlanetNumber) if (minorPlanetNumber)
return; return;
minorPlanetNumber = number; minorPlanetNumber = number;
} }
skipping to change at line 215 skipping to change at line 208
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&ObjectType) if (flags&ObjectType)
{ {
if (pType.length()>0) oss << q_("Type: <b>%1</b>").arg(q_(getPlanetTypeString()))
oss << q_("Type: <b>%1</b>").arg(q_(pType)) << "<br << "<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>)"). arg(QString::number(getVMagnitude(core), 'f', 2), oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)"). arg(QString::number(getVMagnitude(core), 'f', 2),
QString::number(getVMagnitudeWithExtinction(core), 'f', 2)) << "<br>"; QString::number(getVMagnitudeWithExtinction(core), 'f', 2)) << "<br>";
else else
oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0 , 'f', 2) << "<br>"; oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0 , 'f', 2) << "<br>";
skipping to change at line 277 skipping to change at line 269
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&Extra) && (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
/*
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 );
*/
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);
skipping to change at line 309 skipping to change at line 295
float MinorPlanet::getVMagnitude(const StelCore* core) const float MinorPlanet::getVMagnitude(const StelCore* core) const
{ {
//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); 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 :)) //(this is actually vector subtraction + the cosine theorem :))
// GZ Try now in float... speed difference is negligible, though.
const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipti cPos(); const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipti cPos();
const double observerRq = observerHelioPos.lengthSquared(); const float observerRq = observerHelioPos.lengthSquared();
const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos();
const double planetRq = planetHelioPos.lengthSquared(); const float planetRq = planetHelioPos.lengthSquared();
const double observerPlanetRq = (observerHelioPos - planetHelioPos). const float observerPlanetRq = (observerHelioPos - planetHelioPos).l
lengthSquared(); engthSquared();
const double cos_chi = (observerPlanetRq + planetRq - observerRq)/(2 const float cos_chi = (observerPlanetRq + planetRq - observerRq)/(2.
.0*sqrt(observerPlanetRq*planetRq)); 0*std::sqrt(observerPlanetRq*planetRq));
double phaseAngle = std::acos(cos_chi); const float 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) const float tanPhaseAngleHalf=std::tan(phaseAngle*0.5f);
, 0.63)); const float phi1 = std::exp(-3.33f * std::pow(tanPhaseAngleHalf, 0.6
const double phi2 = std::exp(-1.87 * std::pow(std::tan(phaseAngle/2) 3f));
, 1.22)); const float phi2 = std::exp(-1.87f * std::pow(tanPhaseAngleHalf, 1.2
double reducedMagnitude = absoluteMagnitude - 2.5 * std::log10( (1 - 2f));
slopeParameter) * phi1 + slopeParameter * phi2 ); float reducedMagnitude = absoluteMagnitude - 2.5f * std::log10( (1.0
f - slopeParameter) * phi1 + slopeParameter * phi2 );
//Calculate apparent magnitude //Calculate apparent magnitude
//TODO: See if you can "collapse" some calculations float apparentMagnitude = reducedMagnitude + 5.0f * std::log10(std::
// -- GZ: NO! This is also in Meeus, Astr.Alg. 1998, p.231 and autho sqrt(planetRq * observerPlanetRq));
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));
return apparentMagnitude; return apparentMagnitude;
} }
void MinorPlanet::translateName(const 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('*');
skipping to change at line 360 skipping to change at line 345
{ {
return (QString("%1<sub>%2</sub>").arg(main).arg(suf fix)); return (QString("%1<sub>%2</sub>").arg(main).arg(suf fix));
} }
else else
{ {
return main; return main;
} }
} }
else else
{ {
//qDebug() << "renderProvisionalDesignationinHtml():" << pla
inTextName
// << "is not a provisional designation in plain tex
t.";
return QString(); return QString();
} }
} }
 End of changes. 12 change blocks. 
49 lines changed or deleted 26 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/