float MinorPlanet::getVMagnitude(const StelCore* core) const { //If the H-G system is not used, use the default radius/albedo mechanism if (slopeParameter < 0) { return Planet::getVMagnitude(core); } //Calculate phase angle //(Code copied from Planet::getVMagnitude()) //(this is actually vector subtraction + the cosine theorem :)) const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipticPos(); const float observerRq = observerHelioPos.lengthSquared(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const float planetRq = planetHelioPos.lengthSquared(); const float observerPlanetRq = (observerHelioPos - planetHelioPos).lengthSquared(); const float cos_chi = (observerPlanetRq + planetRq - observerRq)/(2.0*std::sqrt(observerPlanetRq*planetRq)); const float phaseAngle = std::acos(cos_chi); //Calculate reduced magnitude (magnitude without the influence of distance) //Source of the formulae: http://www.britastro.org/asteroids/dymock4.pdf const float tanPhaseAngleHalf=std::tan(phaseAngle*0.5f); const float phi1 = std::exp(-3.33f * std::pow(tanPhaseAngleHalf, 0.63f)); const float phi2 = std::exp(-1.87f * std::pow(tanPhaseAngleHalf, 1.22f)); float reducedMagnitude = absoluteMagnitude - 2.5f * std::log10( (1.0f - slopeParameter) * phi1 + slopeParameter * phi2 ); //Calculate apparent magnitude float apparentMagnitude = reducedMagnitude + 5.0f * std::log10(std::sqrt(planetRq * observerPlanetRq)); return apparentMagnitude; }
float MinorPlanet::getVMagnitude(const StelCore* core) const { //If the H-G system is not used, use the default radius/albedo mechanism if (slopeParameter < 0) { return Planet::getVMagnitude(core); } //Calculate phase angle //(Code copied from Planet::getVMagnitude()) //(LOL, this is actually vector subtraction + the cosine theorem :)) const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipticPos(); const double observerRq = observerHelioPos.lengthSquared(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const double planetRq = planetHelioPos.lengthSquared(); const double observerPlanetRq = (observerHelioPos - planetHelioPos).lengthSquared(); const double cos_chi = (observerPlanetRq + planetRq - observerRq)/(2.0*sqrt(observerPlanetRq*planetRq)); double phaseAngle = std::acos(cos_chi); //Calculate reduced magnitude (magnitude without the influence of distance) //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 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 ); //Calculate apparent magnitude //TODO: See if you can "collapse" some calculations // -- GZ: NO! This is also in Meeus, Astr.Alg. 1998, p.231 and authoritative by IAU commission 20, New Delhi November 1985. // (you can collapse and leave away the reducedMagnitude varable, but this is cosmetic) double apparentMagnitude = reducedMagnitude + 5 * std::log10(std::sqrt(planetRq * observerPlanetRq)); return apparentMagnitude; }
float Comet::getVMagnitude(const StelCore* core, bool withExtinction) const { //If the two parameter system is not used, //use the default radius/albedo mechanism if (slopeParameter < 0) { return Planet::getVMagnitude(core, withExtinction); } float extinctionMag=0.0; // track magnitude loss if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) { Vec3d altAz=getAltAzPosApparent(core); altAz.normalize(); core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinctionMag); } //Calculate distances const Vec3d& observerHeliocentricPosition = core->getObserverHeliocentricEclipticPos(); const Vec3d& cometHeliocentricPosition = getHeliocentricEclipticPos(); const double cometSunDistance = std::sqrt(cometHeliocentricPosition.lengthSquared()); const double observerCometDistance = std::sqrt((observerHeliocentricPosition - cometHeliocentricPosition).lengthSquared()); //Calculate apparent magnitude //Sources: http://www.clearskyinstitute.com/xephem/help/xephem.html#mozTocId564354 //(XEphem manual, section 7.1.2.3 "Magnitude models"), also //http://www.ayton.id.au/gary/Science/Astronomy/Ast_comets.htm#Comet%20facts: double apparentMagnitude = absoluteMagnitude + 5 * std::log10(observerCometDistance) + 2.5 * slopeParameter * std::log10(cometSunDistance); return apparentMagnitude + extinctionMag; }
float Comet::getVMagnitude(const StelCore* core) const { //If the two parameter system is not used, //use the default radius/albedo mechanism if (slopeParameter < 0) { return Planet::getVMagnitude(core); } //Calculate distances const Vec3d& observerHeliocentricPosition = core->getObserverHeliocentricEclipticPos(); const Vec3d& cometHeliocentricPosition = getHeliocentricEclipticPos(); const double cometSunDistance = cometHeliocentricPosition.length(); const double observerCometDistance = (observerHeliocentricPosition - cometHeliocentricPosition).length(); //Calculate apparent magnitude //Sources: http://www.clearskyinstitute.com/xephem/help/xephem.html#mozTocId564354 //(XEphem manual, section 7.1.2.3 "Magnitude models"), also //http://www.ayton.id.au/gary/Science/Astronomy/Ast_comets.htm#Comet%20facts: // GZ: Note that Meeus, Astr.Alg.1998 p.231, has m=absoluteMagnitude+5log10(observerCometDistance) + kappa*log10(cometSunDistance) // with kappa typically 5..15. MPC provides Slope parameter. So we should expect to have slopeParameter (a word only used for minor planets!) for our comets 2..6 double apparentMagnitude = absoluteMagnitude + 5 * std::log10(observerCometDistance) + 2.5 * slopeParameter * std::log10(cometSunDistance); return apparentMagnitude; }
// Formula found at http://www.projectpluto.com/update7b.htm#comet_tail_formula Vec2f Comet::getComaDiameterAndTailLengthAU() const { float r = getHeliocentricEclipticPos().length(); float mhelio = absoluteMagnitude + slopeParameter * log10(r); float Do = pow(10.0f, ((-0.0033f*mhelio - 0.07f) * mhelio + 3.25f)); float common = 1.0f - pow(10.0f, (-2.0f*r)); float D = Do * common * (1.0f - pow(10.0f, -r)) * (1000.0f*AU_KM); float Lo = pow(10.0f, ((-0.0075f*mhelio - 0.19f) * mhelio + 2.1f)); float L = Lo*(1.0f-pow(10.0f, -4.0f*r)) * common * (1e6*AU_KM); return Vec2f(D, L); }
QString Comet::getInfoString(const StelCore *core, const InfoStringGroup &flags) const { //Mostly copied from Planet::getInfoString(): QString str; QTextStream oss(&str); if (flags&Name) { oss << "<h2>"; oss << q_(englishName); // UI translation can differ from sky translation oss.setRealNumberNotation(QTextStream::FixedNotation); oss.setRealNumberPrecision(1); if (sphereScale != 1.f) oss << QString::fromUtf8(" (\xC3\x97") << sphereScale << ")"; oss << "</h2>"; } if (flags&ObjectType) { if (pType.length()>0) oss << q_("Type: <b>%1</b>").arg(q_(pType)) << "<br />"; } if (flags&Magnitude) { if (core->getSkyDrawer()->getFlagHasAtmosphere()) 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>"; else oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0, 'f', 2) << "<br>"; } if (flags&AbsoluteMagnitude) { //TODO: Make sure absolute magnitude is a sane value //If the two parameter magnitude system is not use, don't display this //value. (Using radius/albedo doesn't make any sense for comets.) if (slopeParameter >= 0) oss << q_("Absolute Magnitude: %1").arg(absoluteMagnitude, 0, 'f', 2) << "<br>"; } oss << getPositionInfoString(core, flags); if (flags&Distance) { // GZ: Distance from sun should be added to all planets IMHO. double distanceAu = getHeliocentricEclipticPos().length(); double distanceKm = AU * distanceAu; if (distanceAu < 0.1) { // xgettext:no-c-format oss << QString(q_("Distance from Sun: %1AU (%2 km)")) .arg(distanceAu, 0, 'f', 6) .arg(distanceKm, 0, 'f', 3); } else { // xgettext:no-c-format oss << QString(q_("Distance from Sun: %1AU (%2 Mio km)")) .arg(distanceAu, 0, 'f', 3) .arg(distanceKm / 1.0e6, 0, 'f', 3); } oss << "<br>"; distanceAu = getJ2000EquatorialPos(core).length(); distanceKm = AU * distanceAu; if (distanceAu < 0.1) { // xgettext:no-c-format oss << QString(q_("Distance: %1AU (%2 km)")) .arg(distanceAu, 0, 'f', 6) .arg(distanceKm, 0, 'f', 3); } else { // xgettext:no-c-format oss << QString(q_("Distance: %1AU (%2 Mio km)")) .arg(distanceAu, 0, 'f', 3) .arg(distanceKm / 1.0e6, 0, 'f', 3); } oss << "<br>"; // GZ: Add speed. I don't know where to place that bit of information. // xgettext:no-c-format oss << QString(q_("Speed: %1 km/s")) .arg(((CometOrbit*)userDataPtr)->getVelocity().length()*AU/86400.0, 0, 'f', 3); oss << "<br>"; } /* if (flags&Size) oss << q_("Apparent diameter: %1").arg(StelUtils::radToDmsStr(2.*getAngularSize(core)*M_PI/180., true)); */ // If semi-major axis not zero then calculate and display orbital period for comet in days double siderealPeriod = getSiderealPeriod(); if ((flags&Extra) && (siderealPeriod>0)) { // TRANSLATORS: Sidereal (orbital) period for solar system bodies in days and in Julian years (symbol: a) oss << q_("Sidereal period: %1 days (%2 a)").arg(QString::number(siderealPeriod, 'f', 2)).arg(QString::number(siderealPeriod/365.25, 'f', 3)) << "<br>"; } postProcessInfoString(str, flags); return str; }