Stellarium 0.11.0
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/RefractionExtinction.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2010 Fabien Chereau
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  *
00019  * Refraction and extinction computations.
00020  * Implementation: 2010-03-23 GZ=Georg Zotti, Georg.Zotti@univie.ac.at
00021  * 2010-12 FC split into 2 classes, implemented Refraction */
00022 
00023 #ifndef _REFRACTIONEXTINCTION_HPP_
00024 #define _REFRACTIONEXTINCTION_HPP_
00025 // USABILITY: added 3 more flags/switches in GUI:
00026 // Temperature [C] [influences refraction]
00027 // Pressure [mbar]  [influences refraction]
00028 // extinction Coeff. k=0...(0.01)...1, [if k=0, no ext. effect]
00029 // SUGGESTION: Allow Temperature/Pressure/ex.Coeff./LightPollution set in the landscape files
00030 
00031 #include "VecMath.hpp"
00032 #include "StelProjector.hpp"
00033 
00047 class Extinction
00048 {
00049 public:
00050     Extinction();
00055     void forward(const Vec3d *altAzPos, float *mag, const int num) const;
00056     void forward(const Vec3f *altAzPos, float *mag, const int num) const;
00058     void forward(const double *sinAlt,  float *mag, const int num) const;
00059     void forward(const float  *sinAlt,  float *mag, const int num) const;
00060 
00064     void backward(const Vec3d *altAzPos, float *mag, const int num) const;
00065     void backward(const Vec3f *altAzPos, float *mag, const int num) const;
00067     void backward(const double *sinAlt,  float *mag, const int num) const;
00068     void backward(const float  *sinAlt,  float *mag, const int num) const;
00069 
00072     void setExtinctionCoefficient(float k) { ext_coeff=k; }
00073     float getExtinctionCoefficient() const {return ext_coeff;}
00074 
00075 private:
00083     float airmass(const float cosZ, const bool apparent_z=true) const;
00084 
00086     float ext_coeff;
00089     static const float SUBHORIZONTAL_AIRMASS;
00090 };
00091 
00092 
00093 class Refraction: public StelProjector::ModelViewTranform
00094 {
00095 public:
00096     Refraction();
00097 
00101     void forward(Vec3d& altAzPos) const;
00102 
00106     void backward(Vec3d& altAzPos) const;
00107 
00111     void forward(Vec3f& altAzPos) const;
00112 
00116     void backward(Vec3f& altAzPos) const;
00117 
00118     void combine(const Mat4d& m)
00119     {
00120         setPreTransfoMat(preTransfoMat*m);
00121     }
00122 
00123     Mat4d getApproximateLinearTransfo() const {return postTransfoMat*preTransfoMat;}
00124 
00125     StelProjector::ModelViewTranformP clone() const {Refraction* refr = new Refraction(); *refr=*this; return StelProjector::ModelViewTranformP(refr);}
00126 
00128     void setPressure(float p_mbar);
00129     float getPressure() const {return pressure;}
00130 
00132     void setTemperature(float t_C);
00133     float getTemperature() const {return temperature;}
00134 
00136     void setPreTransfoMat(const Mat4d& m);
00137     void setPostTransfoMat(const Mat4d& m);
00138 
00139 private:
00141     void updatePrecomputed();
00142 
00145     float pressure;
00147     float temperature;
00149     float press_temp_corr_Saemundson;
00151     float press_temp_corr_Bennett;
00152 
00154     static const double MIN_GEO_ALTITUDE_DEG;
00155     static const double MIN_GEO_ALTITUDE_RAD;
00156     static const double MIN_GEO_ALTITUDE_SIN;
00157     static const double MIN_APP_ALTITUDE_DEG;
00158     static const double MIN_APP_ALTITUDE_RAD;
00159     static const double MIN_APP_ALTITUDE_SIN;
00160     static const float MIN_GEO_ALTITUDE_DEG_F;
00161     static const float MIN_GEO_ALTITUDE_RAD_F;
00162     static const float MIN_GEO_ALTITUDE_SIN_F;
00163     static const float MIN_APP_ALTITUDE_DEG_F;
00164     static const float MIN_APP_ALTITUDE_RAD_F;
00165     static const float MIN_APP_ALTITUDE_SIN_F;
00166     static const double TRANSITION_WIDTH_GEO_DEG;
00167     static const double TRANSITION_WIDTH_GEO_DEG_F;
00168     static const double TRANSITION_WIDTH_APP_DEG;
00169     static const double TRANSITION_WIDTH_APP_DEG_F;
00170 
00172     Mat4d preTransfoMat;
00173     Mat4d invertPreTransfoMat;
00174     Mat4f preTransfoMatf;
00175     Mat4f invertPreTransfoMatf;
00176 
00178     Mat4d postTransfoMat;
00179     Mat4d invertPostTransfoMat;
00180     Mat4f postTransfoMatf;
00181     Mat4f invertPostTransfoMatf;
00182 };
00183 
00184 #endif  // _REFRACTIONEXTINCTION_HPP_