RefractionExtinction.cpp   RefractionExtinction.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.
* *
* Refraction and extinction computations. * Refraction and extinction computations.
* Principal implementation: 2010-03-23 GZ=Georg Zotti, Georg.Zotti@univie. ac.at * Principal implementation: 2010-03-23 GZ=Georg Zotti, Georg.Zotti@univie. ac.at
*/ */
#include <qsettings.h>
#include "StelApp.hpp"
#include "RefractionExtinction.hpp" #include "RefractionExtinction.hpp"
// To be decided: The following should be either 0 or 40 (or 42? ;-) // To be decided: The following should be either 0 or 40 (or 42? ;-)
const float Extinction::SUBHORIZONTAL_AIRMASS=0.0f; float Extinction::SUBHORIZONTAL_AIRMASS=0.0f;
Extinction::Extinction() : ext_coeff(0.20f) Extinction::Extinction() : ext_coeff(0.20f)
{ {
QSettings* conf = StelApp::getInstance().getSettings();
SUBHORIZONTAL_AIRMASS = (conf->value("astro/flag_extinction_below_horiz
on", true).toBool()? 42.0f : 0.0f);
} }
// altAzPos is the normalized star position vector AFTER REFRACTION, and i ts z component sin(altitude). // altAzPos is the NORMALIZED (!!!) star position vector AFTER REFRACTION, and its z component sin(altitude).
void Extinction::forward(const Vec3d *altAzPos, float *mag, const int num) const void Extinction::forward(const Vec3d *altAzPos, float *mag, const int num) const
{ {
for (int i=0; i<num; ++i) mag[i] += airmass(altAzPos[i][2], true) * ext_coeff; for (int i=0; i<num; ++i) mag[i] += airmass(altAzPos[i][2], true) * ext_coeff;
} }
void Extinction::forward(const Vec3f *altAzPos, float *mag, const int num) const void Extinction::forward(const Vec3f *altAzPos, float *mag, const int num) const
{ {
for (int i=0; i<num; ++i) mag[i] += airmass(altAzPos[i][2], true) * ext_coeff; for (int i=0; i<num; ++i) mag[i] += airmass(altAzPos[i][2], true) * ext_coeff;
} }
// If only sin(altitude) is available: // If only sin(altitude) is available:
void Extinction::forward(const double *sinAlt, float *mag, const int num) c onst void Extinction::forward(const double *sinAlt, float *mag, const int num) c onst
{ {
for (int i=0; i<num; ++i) mag[i] += airmass(sinAlt[i], true) * ext_c oeff; for (int i=0; i<num; ++i) mag[i] += airmass(sinAlt[i], true) * ext_c oeff;
} }
void Extinction::forward(const float *sinAlt, float *mag, const int num) co nst void Extinction::forward(const float *sinAlt, float *mag, const int num) co nst
{ {
for (int i=0; i<num; ++i) mag[i] += airmass(sinAlt[i], true) * ext_c oeff; for (int i=0; i<num; ++i) mag[i] += airmass(sinAlt[i], true) * ext_c oeff;
} }
void Extinction::forward(const double *sinAlt, float *mag) const
{
*mag += airmass(*sinAlt, true) * ext_coeff;
}
void Extinction::forward(const float *sinAlt, float *mag) const
{
*mag += airmass(*sinAlt, true) * ext_coeff;
}
// from observed magnitude in apparent (observed) altitude to atmosphere-fr ee mag, still in apparent, refracted altitude. // from observed magnitude in apparent (observed) altitude to atmosphere-fr ee mag, still in apparent, refracted altitude.
void Extinction::backward(const Vec3d *altAzPos, float *mag, const int num) const void Extinction::backward(const Vec3d *altAzPos, float *mag, const int num) const
{ {
for (int i=0; i<num; ++i) mag[i] -= airmass(altAzPos[i][2], true) * ext_coeff; for (int i=0; i<num; ++i) mag[i] -= airmass(altAzPos[i][2], true) * ext_coeff;
} }
void Extinction::backward(const Vec3f *altAzPos, float *mag, const int num) const void Extinction::backward(const Vec3f *altAzPos, float *mag, const int num) const
{ {
for (int i=0; i<num; ++i) mag[i] -= airmass(altAzPos[i][2], true) * ext_coeff; for (int i=0; i<num; ++i) mag[i] -= airmass(altAzPos[i][2], true) * ext_coeff;
} }
// If only sin(altitude) is available: // If only sin(altitude) is available:
skipping to change at line 72 skipping to change at line 84
for (int i=0; i<num; ++i) mag[i] -= airmass(sinAlt[i], true) * ext_c oeff; for (int i=0; i<num; ++i) mag[i] -= airmass(sinAlt[i], true) * ext_c oeff;
} }
void Extinction::backward(const float *sinAlt, float *mag, const int num) c onst void Extinction::backward(const float *sinAlt, float *mag, const int num) c onst
{ {
for (int i=0; i<num; ++i) mag[i] -= airmass(sinAlt[i], true) * ext_c oeff; for (int i=0; i<num; ++i) mag[i] -= airmass(sinAlt[i], true) * ext_c oeff;
} }
// airmass computation for cosine of zenith angle z // airmass computation for cosine of zenith angle z
float Extinction::airmass(const float cosZ, const bool apparent_z) const float Extinction::airmass(const float cosZ, const bool apparent_z) const
{ {
if (cosZ<-0.035f) if (cosZ<-0.035f) // about -2 degrees. Here, RozenbergZ>574 and clim bs fast!
return Extinction::SUBHORIZONTAL_AIRMASS; // Safety: 0 or 40 for below -2 degrees. return Extinction::SUBHORIZONTAL_AIRMASS; // Safety: 0 or 40 for below -2 degrees.
float X; float X;
if (apparent_z) if (apparent_z)
{ {
// Rozenberg 1966, reported by Schaefer (1993-2000). // Rozenberg 1966, reported by Schaefer (1993-2000).
X=1.0f/(cosZ+0.025f*std::exp(-11.f*cosZ)); X=1.0f/(cosZ+0.025f*std::exp(-11.f*cosZ));
} }
else else
{ {
//Young 1994 //Young 1994
float nom=(1.002432f*cosZ+0.148386f)*cosZ+0.0096467f; float nom=(1.002432f*cosZ+0.148386f)*cosZ+0.0096467f;
float denum=((cosZ+0.149864f)*cosZ+0.0102963f)*cosZ+0.000303 978f; float denum=((cosZ+0.149864f)*cosZ+0.0102963f)*cosZ+0.000303 978f;
X=nom/denum; X=nom/denum;
} }
return X; return X;
} }
/* ************************************************************************
***************************** */
// The following 4 are to be configured, the rest is derived. // The following 4 are to be configured, the rest is derived.
// Recommendations: -4.9/-4.3/0.1/0.1: sharp but continuous transition, no effects below -5. // Recommendations: -4.9/-4.3/0.1/0.1: sharp but continuous transition, no effects below -5.
// -4.3/-4.3/0.7/0.7: sharp but continuous transition, no effects below -5. Maybe better for picking? // -4.3/-4.3/0.7/0.7: sharp but continuous transition, no effects below -5. Maybe better for picking?
// -3/-3/2/2: "strange" zone 2 degrees wide. Both formulae are close near -3. Actually, refraction formulae dubious below 0 // -3/-3/2/2: "strange" zone 2 degrees wide. Both formulae are close near -3. Actually, refraction formulae dubious below 0
// 0/0/1/1: "strange zone 1 degree wide just below horizo n, no effect below -1. Actually, refraction formulae dubious below 0! But i t looks stupid, see the sun! // 0/0/1/1: "strange zone 1 degree wide just below horizo n, no effect below -1. Actually, refraction formulae dubious below 0! But i t looks stupid, see the sun!
// Optimum:-3.54/-3.21783/1.46/1.78217. Here forward/backw ard are almost perfect inverses (-->good picking!), and nothing happens bel ow -5 degrees. // Optimum:-3.54/-3.21783/1.46/1.78217. Here forward/backw ard are almost perfect inverses (-->good picking!), and nothing happens bel ow -5 degrees.
// This must be -5 or higher. // This must be -5 or higher.
const double Refraction::MIN_GEO_ALTITUDE_DEG=-3.54; const double Refraction::MIN_GEO_ALTITUDE_DEG=-3.54;
// this must be -4.3 or higher. -3.21783 is an optimal value to fit against forward refraction! // this must be -4.3 or higher. -3.21783 is an optimal value to fit against forward refraction!
const double Refraction::MIN_APP_ALTITUDE_DEG=-3.21783; const double Refraction::MIN_APP_ALTITUDE_DEG=-3.21783;
 End of changes. 8 change blocks. 
4 lines changed or deleted 20 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/