RefractionExtinction.hpp   RefractionExtinction.hpp 
skipping to change at line 51 skipping to change at line 51
//! 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 terrestrial locations, not on Moon/Mars/Saturn etc //! (2) only for terrestrial locations, not on Moon/Mars/Saturn etc
//! config.ini:astro/flag_extinction_below_horizon=true|false controls if e xtinction kills objects below -2 degrees altitude by setting airmass to 42. //! config.ini:astro/flag_extinction_below_horizon=true|false controls if e xtinction kills objects below -2 degrees altitude by setting airmass to 42.
class Extinction class Extinction
{ {
public: public:
Extinction(); Extinction();
//! Compute extinction effect for arrays of size @param num position vectors and magnitudes. //! Compute extinction effect for arrays of size @param num position vectors and magnitudes.
//! @param altAzPos are the NORMALIZED (!!) (apparent) star position vectors, and their z components sin(apparent_altitude). //! @param altAzPos are the NORMALIZED (!!) (apparent) star position vectors, and their z components sin(apparent_altitude).
//! @param mag the magnitudes
//! This call must therefore be done after application of Refraction , and only if atmospheric effects are on. //! 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(const Vec3d *altAzPos, float *mag, const int num=1) con st; void forward(const Vec3d *altAzPos, float *mag, const int num=1) con st;
void forward(const Vec3f *altAzPos, float *mag, const int num=1) con st; void forward(const Vec3f *altAzPos, float *mag, const int num=1) con st;
void forward(const double *sinAlt, float *mag, const int num) const ; void forward(const double *sinAlt, float *mag, const int num) const ;
void forward(const float *sinAlt, float *mag, const int num) const ; void forward(const float *sinAlt, float *mag, const int num) const ;
void forward(const double *sinAlt, float *mag) const; void forward(const double *sinAlt, float *mag) const;
void forward(const float *sinAlt, float *mag) const; void forward(const float *sinAlt, float *mag) const;
//! Compute inverse extinction effect for arrays of size @param num position vectors and magnitudes. //! Compute inverse extinction effect for arrays of size @param num position vectors and magnitudes.
//! @param altAzPos are the NORMALIZED (!!) (apparent) star position vectors, and their z components sin(apparent_altitude). //! @param altAzPos are the NORMALIZED (!!) (apparent) star position vectors, and their z components sin(apparent_altitude).
//! @param mag the magnitudes
//! Note that forward/backward are no absolute reverse operations! //! Note that forward/backward are no absolute reverse operations!
void backward(const Vec3d *altAzPos, float *mag, const int num=1) co nst; void backward(const Vec3d *altAzPos, float *mag, const int num=1) co nst;
void backward(const Vec3f *altAzPos, float *mag, const int num=1) co nst; void backward(const Vec3f *altAzPos, float *mag, const int num=1) co nst;
void backward(const double *sinAlt, float *mag, const int num=1) co nst; void backward(const double *sinAlt, float *mag, const int num=1) co nst;
void backward(const float *sinAlt, float *mag, const int num=1) co nst; void backward(const float *sinAlt, float *mag, const int num=1) co nst;
//! 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) { ext_coeff=k; } void setExtinctionCoefficient(float k) { ext_coeff=k; }
float getExtinctionCoefficient() const {return ext_coeff;} float getExtinctionCoefficient() const {return ext_coeff;}
skipping to change at line 108 skipping to change at line 110
//! (3) only for terrestrial locations, not on Moon/Mars/Saturn etc //! (3) only for terrestrial locations, not on Moon/Mars/Saturn etc
class Refraction: public StelProjector::ModelViewTranform class Refraction: public StelProjector::ModelViewTranform
{ {
public: public:
Refraction(); Refraction();
//! Apply refraction. //! Apply refraction.
//! @param altAzPos is the geometrical star position vector, to be t ransformed into apparent position. //! @param altAzPos is the geometrical star position vector, to be t ransformed into apparent position.
//! Note that forward/backward are no absolute reverse operations! //! Note that forward/backward are no absolute reverse operations!
void forward(Vec3d& altAzPos) const; virtual void forward(Vec3d& altAzPos) const;
//! Remove refraction from position ("reduce"). //! Remove refraction from position ("reduce").
//! @param altAzPos is the apparent star position vector, to be tran sformed into geometrical position. //! @param altAzPos is the apparent star position vector, to be tran sformed into geometrical position.
//! Note that forward/backward are no absolute reverse operations! //! Note that forward/backward are no absolute reverse operations!
void backward(Vec3d& altAzPos) const; virtual void backward(Vec3d& altAzPos) const;
//! Apply refraction. //! Apply refraction.
//! @param altAzPos is the geometrical star position vector, to be t ransformed into apparent position. //! @param altAzPos is the geometrical star position vector, to be t ransformed into apparent position.
//! Note that forward/backward are no absolute reverse operations! //! Note that forward/backward are no absolute reverse operations!
void forward(Vec3f& altAzPos) const; virtual void forward(Vec3f& altAzPos) const;
//! Remove refraction from position ("reduce"). //! Remove refraction from position ("reduce").
//! @param altAzPos is the apparent star position vector, to be tran sformed into geometrical position. //! @param altAzPos is the apparent star position vector, to be tran sformed into geometrical position.
//! Note that forward/backward are no absolute reverse operations! //! Note that forward/backward are no absolute reverse operations!
void backward(Vec3f& altAzPos) const; virtual void backward(Vec3f& altAzPos) const;
void combine(const Mat4d& m) virtual void combine(const Mat4d& m)
{ {
setPreTransfoMat(preTransfoMat*m); setPreTransfoMat(preTransfoMat*m);
} }
Mat4d getApproximateLinearTransfo() const {return postTransfoMat*pre TransfoMat;} virtual Mat4d getApproximateLinearTransfo() const {return postTransf oMat*preTransfoMat;}
StelProjector::ModelViewTranformP clone() const {Refraction* refr = virtual StelProjector::ModelViewTranformP clone() const {Refraction*
new Refraction(); *refr=*this; return StelProjector::ModelViewTranformP(ref refr = new Refraction(); *refr=*this; return StelProjector::ModelViewTranf
r);} ormP(refr);}
virtual bool setupGLSLTransform(StelGLSLShader* shader)
{
Q_UNUSED(shader);
return false;
// GL-REFACTOR:
//
// I reimplemented the forward() member function in GLSL, bu
t the result is
// not usable at the moment.
//
// On Intel drivers, the projection gets completely messed u
p.
// On AMD, most of the time, the coordinates are projected i
n slightly
// different locations (e.g. a planet is slightly above/belo
w where it's
// supposed to be), and there is very nasty jitter on the in
dividual vertex
// positions.
// NVidia behaves the same, _and_ the viewport borders are m
essed up.
//
//
// The most likely cause of the problem is the imprecision o
f GLSL
// sin, asin and tan (which AFAIK are implemented through lo
w-resolution
// lookup tables in hardware).
//
// However, it is also possible that I incorrectly translate
d forward() to
// GLSL.
//
//
// Different possible ways to implement refraction in GLSL w
ould be
// to use custom, higher-resolution lookup tables (textures)
, or to use
// a different, maybe simpler (less trig) algorithm for refr
action.
// if(!shader->hasVertexShader("RefractionTransform"))
// {
// static const QString source(
// "uniform mat4 preTransfoMat;\n"
// "uniform mat4 postTransfoMat;\n"
// "uniform float press_temp_corr_Saemundson;\n
"
// "// These values must match the C++ code.\n"
// "const float MIN_GEO_ALTITUDE_DEG = -3.54;\n
"
// "const float TRANSITION_WIDTH_GEO_DEG = 1.46
;\n"
// "\n"
// "vec4 modelViewForward(in vec4 altAzPos)\n"
// "{\n"
// " vec4 localAltAzPos = preTransfoMat * al
tAzPos;\n"
// " float len = length(localAltAzPos.xyz);\
n"
// " float geom_alt_deg = degrees(asin(local
AltAzPos.z / len));\n"
// " if(geom_alt_deg > MIN_GEO_ALTITUDE_DEG)
\n"
// " {\n"
// " // refraction from Saemundsson, S&T
1986 p70 / in Meeus, Astr.Alg.\n"
// " float r = press_temp_corr_Saemundso
n / \n"
// " tan(radians(geom_alt_deg
+ 10.3 / (geom_alt_deg + 5.11))) + 0.0019279;\n"
// " geom_alt_deg += r;\n"
// " geom_alt_deg = min(geom_alt_deg, 90
.0); // SAFETY\n"
// " localAltAzPos.z = sin(radians(geom_
alt_deg)) * len;\n"
// " }\n"
// " else if(geom_alt_deg > (MIN_GEO_ALTITUD
E_DEG - TRANSITION_WIDTH_GEO_DEG))\n"
// " {\n"
// " // Avoids the jump below -5 by inte
rpolating linearly between\n"
// " // MIN_GEO_ALTITUDE_DEG and bottom
of transition zone\n"
// " float r_m5 = press_temp_corr_Saemun
dson / \n"
// " tan(radians(MIN_GEO_AL
TITUDE_DEG + 10.3 / (MIN_GEO_ALTITUDE_DEG + 5.11)))\n"
// " + 0.0019279;\n"
// " geom_alt_deg += r_m5 * \n"
// " (geom_alt_deg - (MI
N_GEO_ALTITUDE_DEG - TRANSITION_WIDTH_GEO_DEG)) /\n"
// " TRANSITION_WIDTH_GE
O_DEG;\n"
// " localAltAzPos.z = sin(radians(geom_
alt_deg)) * len;\n"
// " }\n"
// " return postTransfoMat * localAltAzPos;\
n"
// "}\n");
// if(!shader->addVertexShader("RefractionTransform", s
ource))
// {
// return false;
// }
// qDebug() << "Build log after adding a refraction sha
der: " << shader->log();
// }
// shader->enableVertexShader("RefractionTransform");
// return true;
}
virtual void setGLSLUniforms(StelGLSLShader* shader)
{
Q_UNUSED(shader);
// shader->setUniformValue("preTransfoMat", preTransfoMatf);
// shader->setUniformValue("postTransfoMat", postTransfoMatf
);
// shader->setUniformValue("press_temp_corr_Saemundson", pre
ss_temp_corr_Saemundson);
}
virtual void disableGLSLTransform(StelGLSLShader* shader)
{
Q_UNUSED(shader);
// shader->disableVertexShader("RefractionTransform");
}
//! Set surface air pressure (mbars), influences refraction computat ion. //! Set surface air pressure (mbars), influences refraction computat ion.
void setPressure(float p_mbar); void setPressure(float p_mbar);
float getPressure() const {return pressure;} float getPressure() const {return pressure;}
//! Set surface air temperature (degrees Celsius), influences refrac tion computation. //! Set surface air temperature (degrees Celsius), influences refrac tion computation.
void setTemperature(float t_C); void setTemperature(float t_C);
float getTemperature() const {return temperature;} float getTemperature() const {return temperature;}
//! Set the transformation matrices used to transform input vector t o AltAz frame. //! Set the transformation matrices used to transform input vector t o AltAz frame.
 End of changes. 9 change blocks. 
9 lines changed or deleted 141 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/