Stellarium 0.15.2
RefractionExtinction.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2010 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  *
19  * Refraction and extinction computations.
20  * Implementation: 2010-03-23 GZ=Georg Zotti, Georg.Zotti@univie.ac.at
21  * 2010-12 FC split into 2 classes, implemented Refraction */
22 
23 #ifndef _REFRACTIONEXTINCTION_HPP_
24 #define _REFRACTIONEXTINCTION_HPP_
25 // USABILITY: added 3 more flags/switches in GUI:
26 // Temperature [C] [influences refraction]
27 // Pressure [mbar] [influences refraction]
28 // extinction Coeff. k=0...(0.01)...1, [if k=0, no ext. effect]
29 // SUGGESTION: Allow Temperature/Pressure/ex.Coeff./LightPollution set in the landscape files
30 
31 #include "VecMath.hpp"
32 #include "StelProjector.hpp"
33 
46 {
47 public:
53  };
54 
55  Extinction();
56 
61  void forward(const Vec3d& altAzPos, float* mag) const
62  {
63  Q_ASSERT(std::fabs(altAzPos.length()-1.f)<0.001f);
64  *mag += airmass(altAzPos[2], false) * ext_coeff;
65  }
66 
67  void forward(const Vec3f& altAzPos, float* mag) const
68  {
69  Q_ASSERT(std::fabs(altAzPos.length()-1.f)<0.001f);
70  *mag += airmass(altAzPos[2], false) * ext_coeff;
71  }
72 
76  void backward(const Vec3d& altAzPos, float* mag) const
77  {
78  *mag -= airmass(altAzPos[2], false) * ext_coeff;
79  }
80 
81  void backward(const Vec3f& altAzPos, float* mag) const
82  {
83  *mag -= airmass(altAzPos[2], false) * ext_coeff;
84  }
85 
88  void setExtinctionCoefficient(float k) { ext_coeff=k; }
89  float getExtinctionCoefficient() const {return ext_coeff;}
90 
91  void setUndergroundExtinctionMode(UndergroundExtinctionMode mode) {undergroundExtinctionMode=mode;}
92  UndergroundExtinctionMode getUndergroundExtinctionMode() const {return undergroundExtinctionMode;}
93 
94 private:
102  float airmass(float cosZ, const bool apparent_z=true) const;
103 
105  float ext_coeff;
106 
108  UndergroundExtinctionMode undergroundExtinctionMode;
109 };
110 
120 
122 {
123 public:
124  Refraction();
125 
129  void forward(Vec3d& altAzPos) const;
130 
134  void backward(Vec3d& altAzPos) const;
135 
139  void forward(Vec3f& altAzPos) const;
140 
144  void backward(Vec3f& altAzPos) const;
145 
146  void combine(const Mat4d& m)
147  {
148  setPreTransfoMat(preTransfoMat*m);
149  }
150 
151  Mat4d getApproximateLinearTransfo() const {return postTransfoMat*preTransfoMat;}
152 
153  StelProjector::ModelViewTranformP clone() const {Refraction* refr = new Refraction(); *refr=*this; return StelProjector::ModelViewTranformP(refr);}
154 
156  void setPressure(float p_mbar);
157  float getPressure() const {return pressure;}
158 
160  void setTemperature(float t_C);
161  float getTemperature() const {return temperature;}
162 
164  void setPreTransfoMat(const Mat4d& m);
165  void setPostTransfoMat(const Mat4d& m);
166 
167 private:
169  void updatePrecomputed();
170 
171  void innerRefractionForward(Vec3d& altAzPos) const;
172  void innerRefractionBackward(Vec3d& altAzPos) const;
173 
176  float pressure;
178  float temperature;
180  float press_temp_corr;
181 
183  Mat4d preTransfoMat;
184  Mat4d invertPreTransfoMat;
185  Mat4f preTransfoMatf;
186  Mat4f invertPreTransfoMatf;
187 
189  Mat4d postTransfoMat;
190  Mat4d invertPostTransfoMat;
191  Mat4f postTransfoMatf;
192  Mat4f invertPostTransfoMatf;
193 };
194 
195 #endif // _REFRACTIONEXTINCTION_HPP_
void setExtinctionCoefficient(float k)
Set visual extinction coefficient (mag/airmass), influences extinction computation.
void backward(const Vec3d &altAzPos, float *mag) const
Compute inverse extinction effect for arrays of size num position vectors and magnitudes.
This class performs extinction computations, following literature from atmospheric optics and astrono...
Allows to define non linear operations in addition to the standard linear (Matrix 4d) ModelView trans...
This class performs refraction computations, following literature from atmospheric optics and astrono...
UndergroundExtinctionMode
Define the extinction strategy for rendering underground objects (useful when ground is not rendered)...
Maximum extinction: coef 42, i.e practically invisible.
Zero extinction: stars visible in full brightness.
QSharedPointer< ModelViewTranform > ModelViewTranformP
Shared pointer on a ModelViewTranform instance (implement reference counting)
void forward(const Vec3d &altAzPos, float *mag) const
Compute extinction effect for arrays of size num position vectors and magnitudes. ...
Mirror the extinction for the same altutide above the ground.