RefractionExtinction.hpp   RefractionExtinction.hpp 
skipping to change at line 21 skipping to change at line 21
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
* *
* Refraction and extinction computations. * Refraction and extinction computations.
* Implementation: 2010-03-23 GZ=Georg Zotti, Georg.Zotti@univie.ac.at * Implementation: 2010-03-23 GZ=Georg Zotti, Georg.Zotti@univie.ac.at
*/ * 2010-12 FC split into 2 classes, implemented Refraction */
// TODO USABILITY: add 4 more flags/switches in GUI: #ifndef _REFRACTIONEXTINCTION_HPP_
// (boolean) refraction, [could be omitted and linked to global "show atmos #define _REFRACTIONEXTINCTION_HPP_
phere"] // USABILITY: added 3 more flags/switches in GUI:
// (value field) Temperature [C] [influences refraction] // Temperature [C] [influences refraction]
// (value field) Pressure [mbar] [influences refraction] // Pressure [mbar] [influences refraction]
// (combo) extinction Coeff. k=0...(0.01)...1, [if k=0, no ext. effect] // extinction Coeff. k=0...(0.01)...1, [if k=0, no ext. effect]
// SUGGESTION: Could Temperature/Pressure/ex.Coeff./LightPollution be linke // SUGGESTION: Allow Temperature/Pressure/ex.Coeff./LightPollution set in t
d to the landscape files? he landscape files
#include "VecMath.hpp" #include "VecMath.hpp"
#include "StelProjector.hpp"
//! @class RefractionExtinction //! @class RefractionExtinction
//! This class performs refraction and extinction computations, following l iterature from atmospheric optics and astronomy. //! This class performs refraction and extinction computations, following l iterature from atmospheric optics and astronomy.
//! Airmass computations are limited to meaningful altitudes, //! Airmass computations are limited to meaningful altitudes,
//! and refraction solutions can only be aproximate, given the turbulent, u npredictable real atmosphere. //! and refraction solutions can only be aproximate, given the turbulent, u npredictable real atmosphere.
//! The solution provided here will [hopefully!] result in a visible "zone of avoidance" near the horizon down to altitude -2, //! The solution provided here will [hopefully!] result in a visible "zone of avoidance" near the horizon down to altitude -2,
//! and will show stars in their full brightness at their geometrical posit ions below -2 degrees. //! and will show stars in their full brightness at their geometrical posit ions below -5 degrees.
//! Of course, plotting stars below the horizon could be coupled to setting of horizon foreground, //! Of course, plotting stars below the horizon could be coupled to setting of horizon foreground,
//! it's another usability issue. Typical horizons do not go down below -1, so -2 should leave a fair amount of room. //! it's another usability issue. Typical horizons do not go down below -1, so strange effects between -2 and -5 should be covered.
//! Note that forward/backward are no absolute reverse operations! //! Note that forward/backward are no absolute reverse operations!
//! All the computations should be in effect //! All the computations should be in effect
//! (1) only if atmosphere effects are true //! (1) only if atmosphere effects are true
//! (2) only for celestial objects, never for landscape coordinates //! (2) only for celestial objects, never for landscape coordinates
//! (3) only for terrestrial locations, not on Moon/Mars/Saturn etc //! (3) only for terrestrial locations, not on Moon/Mars/Saturn etc
class RefractionExtinction class Extinction
{ {
public: public:
RefractionExtinction(); Extinction();
//! Compute refraction and extinction effects for arrays of size @pa //! Compute extinction effect for arrays of size @param num position
ram size position vectors and magnitudes. vectors and magnitudes.
//! @param altAzPos are the normalized (true) star position vectors, //! @param altAzPos are the normalized (apparent) star position vect
and their z components sin(true_altitude). ors, and their z components sin(apparent_altitude).
//! This call must therefore be done after application of Refraction
, and only if atmospheric effects are on.
//! Note that forward/backward are no absolute reverse operations! //! Note that forward/backward are no absolute reverse operations!
void forward(Vec3d* altAzPos, float* mag, int size); void forward(const Vec3d *altAzPos, float *mag, const int num) const
//! Compute refraction and extinction effects for arrays of size @pa ;
ram size position vectors and magnitudes. void forward(const Vec3f *altAzPos, float *mag, const int num) const
;
//! Convenience method for the same
void forward(const double *sinAlt, float *mag, const int num) const
;
void forward(const float *sinAlt, float *mag, const int num) const
;
//! Compute extinction effect for arrays of size @param size positio
n vectors and magnitudes.
//! @param altAzPos are the normalized (apparent) star position vect ors, and their z components sin(apparent_altitude). //! @param altAzPos are the normalized (apparent) star position vect ors, and their z components sin(apparent_altitude).
//! Note that forward/backward are no absolute reverse operations! //! Note that forward/backward are no absolute reverse operations!
void backward(Vec3d* altAzPos, float* mag, int size); void backward(const Vec3d *altAzPos, float *mag, const int num) cons
//! Set surface air pressure (mbars), influences refraction computat t;
ion. void backward(const Vec3f *altAzPos, float *mag, const int num) cons
void setPressure(float p_mbar); t;
//! Set surface air temperature (degrees Celsius), influences refrac //! Convenience method for the same
tion computation. void backward(const double *sinAlt, float *mag, const int num) cons
void setTemperature(float t_C); t;
void backward(const float *sinAlt, float *mag, const int num) cons
t;
//! Set visual extinction coefficient (mag/airmass), influences exti nction computation. //! Set visual extinction coefficient (mag/airmass), influences exti nction computation.
//! @param k= 0.1 for highest mountains, 0.2 for very good lowland l ocations, 0.35 for typical lowland, 0.5 in humid climates. //! @param k= 0.1 for highest mountains, 0.2 for very good lowland l ocations, 0.35 for typical lowland, 0.5 in humid climates.
void setExtinctionCoefficient(float k); void setExtinctionCoefficient(float k) { ext_coeff=k; }
float getExtinctionCoefficient() const {return ext_coeff;}
private:
//! airmass computation for @param cosZ = cosine of zenith angle z ( =sin(altitude)!). //! airmass computation for @param cosZ = cosine of zenith angle z ( =sin(altitude)!).
//! The default (@param apparent_z = true) is computing airmass from observed altitude, following Rozenberg (1966) [X(90)~40]. //! The default (@param apparent_z = true) is computing airmass from observed altitude, following Rozenberg (1966) [X(90)~40].
//! if (@param apparent_z = false), we have geometrical altitude and compute airmass from that, //! if (@param apparent_z = false), we have geometrical altitude and compute airmass from that,
//! following Young: Air mass and refraction. Applied Optics 33(6), pp.1108-1110, 1994. [X(90)~32]. //! following Young: Air mass and refraction. Applied Optics 33(6), pp.1108-1110, 1994. [X(90)~32].
//! A problem ist that refraction depends on air pressure and temper ature, but Young's formula assumes T=15C, p=1013.25mbar. //! A problem ist that refraction depends on air pressure and temper ature, but Young's formula assumes T=15C, p=1013.25mbar.
//! So, it seems better to compute refraction first, and then use th e Rozenberg formula here. //! So, it seems better to compute refraction first, and then use th e Rozenberg formula here.
//! Rozenberg is infinite at Z=92.17 deg, Young at Z=93.6 deg, so th //! Rozenberg is infinite at Z=92.17 deg, Young at Z=93.6 deg, so th
is function has NO EFFECT BELOW -2 DEGREES! is function RETURNS SUBHORIZONTAL_AIRMASS BELOW -2 DEGREES!
float airmass(float cosZ, bool apparent_z=true); float airmass(const float cosZ, const bool apparent_z=true) const;
//! k, magnitudes/airmass, in [0.00, ... 1.00], (default 0.20).
float ext_coeff;
//! should be either 0.0 (stars visible in full brightness below hor
izon) or 40.0 (practically invisible)
//! Maybe make this a user-configurable option?
static const float SUBHORIZONTAL_AIRMASS;
};
class Refraction: public StelProjector::ModelViewTranform
{
public:
Refraction();
//! Apply refraction.
//! @param altAzPos is the geometrical star position vector, to be t
ransformed into apparent position.
//! Note that forward/backward are no absolute reverse operations!
void forward(Vec3d& altAzPos) const;
//! Remove refraction from position ("reduce").
//! @param altAzPos is the apparent star position vector, to be tran
sformed into geometrical position.
//! Note that forward/backward are no absolute reverse operations!
void backward(Vec3d& altAzPos) const;
//! Apply refraction.
//! @param altAzPos is the geometrical star position vector, to be t
ransformed into apparent position.
//! Note that forward/backward are no absolute reverse operations!
void forward(Vec3f& altAzPos) const;
//! Remove refraction from position ("reduce").
//! @param altAzPos is the apparent star position vector, to be tran
sformed into geometrical position.
//! Note that forward/backward are no absolute reverse operations!
void backward(Vec3f& altAzPos) const;
void combine(const Mat4d& m)
{
setPreTransfoMat(preTransfoMat*m);
}
Mat4d getApproximateLinearTransfo() const {return postTransfoMat*pre
TransfoMat;}
StelProjector::ModelViewTranformP clone() const {Refraction* refr =
new Refraction(); *refr=*this; return StelProjector::ModelViewTranformP(ref
r);}
//! Set surface air pressure (mbars), influences refraction computat
ion.
void setPressure(float p_mbar);
float getPressure() const {return pressure;}
//! Set surface air temperature (degrees Celsius), influences refrac
tion computation.
void setTemperature(float t_C);
float getTemperature() const {return temperature;}
//! Set the transformation matrices used to transform input vector t
o AltAz frame.
void setPreTransfoMat(const Mat4d& m);
void setPostTransfoMat(const Mat4d& m);
private: private:
//! Update precomputed variables. //! Update precomputed variables.
void updatePrecomputed(); void updatePrecomputed();
//! Actually, these 3 Atmosphere parameters should be controlled by GUI. //! These 3 Atmosphere parameters can be controlled by GUI.
//! Pressure[mbar] (1013) //! Pressure[mbar] (1013)
float pressure; float pressure;
//! Temperature[Celsius deg] (10). //! Temperature[Celsius deg] (10).
float temperature; float temperature;
//! k, magnitudes/airmass, in [0.00, ... 1.00], (default 0.20).
float ext_coeff;
//! Numerator of refraction formula, to be cached for speed. //! Numerator of refraction formula, to be cached for speed.
float press_temp_corr_Saemundson; float press_temp_corr_Saemundson;
//! Numerator of refraction formula, to be cached for speed. //! Numerator of refraction formula, to be cached for speed.
float press_temp_corr_Bennett; float press_temp_corr_Bennett;
//! These constants are usable for experiments with the limits of re
fraction effects.
static const double MIN_GEO_ALTITUDE_DEG;
static const double MIN_GEO_ALTITUDE_RAD;
static const double MIN_GEO_ALTITUDE_SIN;
static const double MIN_APP_ALTITUDE_DEG;
static const double MIN_APP_ALTITUDE_RAD;
static const double MIN_APP_ALTITUDE_SIN;
static const float MIN_GEO_ALTITUDE_DEG_F;
static const float MIN_GEO_ALTITUDE_RAD_F;
static const float MIN_GEO_ALTITUDE_SIN_F;
static const float MIN_APP_ALTITUDE_DEG_F;
static const float MIN_APP_ALTITUDE_RAD_F;
static const float MIN_APP_ALTITUDE_SIN_F;
static const double TRANSITION_WIDTH_GEO_DEG;
static const double TRANSITION_WIDTH_GEO_DEG_F;
static const double TRANSITION_WIDTH_APP_DEG;
static const double TRANSITION_WIDTH_APP_DEG_F;
//! Used to pretransform coordinates into AltAz frame.
Mat4d preTransfoMat;
Mat4d invertPreTransfoMat;
Mat4f preTransfoMatf;
Mat4f invertPreTransfoMatf;
//! Used to postransform refracted coordinates from AltAz to view.
Mat4d postTransfoMat;
Mat4d invertPostTransfoMat;
Mat4f postTransfoMatf;
Mat4f invertPostTransfoMatf;
}; };
#endif // _REFRACTIONEXTINCTION_HPP_
 End of changes. 16 change blocks. 
34 lines changed or deleted 144 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/