RefractionExtinction.cpp   RefractionExtinction.cpp 
skipping to change at line 232 skipping to change at line 232
+8.052)*Refraction::MIN_APP_ALTITUDE_DEG-11.30 8)*Refraction::MIN_APP_ALTITUDE_DEG+34.341; +8.052)*Refraction::MIN_APP_ALTITUDE_DEG-11.30 8)*Refraction::MIN_APP_ALTITUDE_DEG+34.341;
r_min*=press_temp_corr_Bennett; r_min*=press_temp_corr_Bennett;
obs_alt_deg -= r_min*(obs_alt_deg-(Refraction::MIN_APP_ALTIT UDE_DEG-Refraction::TRANSITION_WIDTH_APP_DEG))/Refraction::TRANSITION_WIDTH _APP_DEG; obs_alt_deg -= r_min*(obs_alt_deg-(Refraction::MIN_APP_ALTIT UDE_DEG-Refraction::TRANSITION_WIDTH_APP_DEG))/Refraction::TRANSITION_WIDTH _APP_DEG;
altAzPos[2]=std::sin(obs_alt_deg*M_PI/180.)*length; altAzPos[2]=std::sin(obs_alt_deg*M_PI/180.)*length;
} }
altAzPos.transfo4d(invertPreTransfoMat); altAzPos.transfo4d(invertPreTransfoMat);
} }
void Refraction::forward(Vec3f& altAzPos) const void Refraction::forward(Vec3f& altAzPos) const
{ {
altAzPos.transfo4d(preTransfoMatf); // Using doubles internally to avoid jitter.
const float length = altAzPos.length(); // (This affects planet drawing - which is done using floats,
float geom_alt_deg=180.f/M_PI*std::asin(altAzPos[2]/length); // as doubles are unsupported/slow on GPUs)
if (geom_alt_deg > Refraction::MIN_GEO_ALTITUDE_DEG_F) Vec3d altAzPosD(altAzPos[0], altAzPos[1], altAzPos[2]);
altAzPosD.transfo4d(preTransfoMat);
const double length = altAzPosD.length();
double geom_alt_deg=180./M_PI*std::asin(altAzPosD[2]/length);
if (geom_alt_deg > Refraction::MIN_GEO_ALTITUDE_DEG)
{ {
// refraction from Saemundsson, S&T1986 p70 / in Meeus, Astr .Alg. // refraction from Saemundsson, S&T1986 p70 / in Meeus, Astr .Alg.
float r=press_temp_corr_Saemundson / std::tan((geom_alt_deg+ double r=press_temp_corr_Saemundson /
10.3f/(geom_alt_deg+5.11f))*M_PI/180.f) + 0.0019279f; std::tan((geom_alt_deg+10.3/(geom_alt_deg+5.11))*M_P
I/180.) + 0.0019279;
geom_alt_deg += r; geom_alt_deg += r;
if (geom_alt_deg > 90.f) geom_alt_deg=90.f; // SAFETY if (geom_alt_deg > 90.) geom_alt_deg=90.; // SAFETY
altAzPos[2]=std::sin(geom_alt_deg*M_PI/180.f)*length; altAzPosD[2]=std::sin(geom_alt_deg*M_PI/180.)*length;
} }
else if(geom_alt_deg>Refraction::MIN_GEO_ALTITUDE_DEG_F-Refraction:: TRANSITION_WIDTH_GEO_DEG_F) else if(geom_alt_deg>Refraction::MIN_GEO_ALTITUDE_DEG-Refraction::TR ANSITION_WIDTH_GEO_DEG)
{ {
// Avoids the jump below -5 by interpolating linearly betwee // Avoids the jump below -5 by interpolating linearly betwee
n MIN_GEO_ALTITUDE_DEG_F and bottom of transition zone n MIN_GEO_ALTITUDE_DEG and bottom of transition zone
float r_m5=press_temp_corr_Saemundson / std::tan((Refraction double r_m5=press_temp_corr_Saemundson /
::MIN_GEO_ALTITUDE_DEG_F+10.3f/(Refraction::MIN_GEO_ALTITUDE_DEG_F+5.11f))* std::tan((Refraction::MIN_GEO_ALTITUDE_DEG+10.3/
M_PI/180.f) + 0.0019279f; (Refraction::MIN_GEO_ALTITUDE_DEG+5.11))
geom_alt_deg += r_m5*(geom_alt_deg-(Refraction::MIN_GEO_ALTI *M_PI/180.) + 0.0019279;
TUDE_DEG_F-Refraction::TRANSITION_WIDTH_GEO_DEG_F))/Refraction::TRANSITION_ geom_alt_deg +=
WIDTH_GEO_DEG_F; r_m5*(geom_alt_deg-(Refraction::MIN_GEO_ALTITUDE_DEG
altAzPos[2]=std::sin(geom_alt_deg*M_PI/180.)*length; -
Refraction::TRANSITION_WIDTH_GEO
_DEG))
/Refraction::TRANSITION_WIDTH_GEO_DEG;
altAzPosD[2]=std::sin(geom_alt_deg*M_PI/180.)*length;
} }
altAzPos.transfo4d(postTransfoMatf); altAzPosD.transfo4d(postTransfoMat);
altAzPos = Vec3f(altAzPosD[0], altAzPosD[1], altAzPosD[2]);
} }
void Refraction::backward(Vec3f& altAzPos) const void Refraction::backward(Vec3f& altAzPos) const
{ {
altAzPos.transfo4d(invertPostTransfoMatf); altAzPos.transfo4d(invertPostTransfoMatf);
// going from observed position/magnitude to geometrical position an d atmosphere-free mag. // going from observed position/magnitude to geometrical position an d atmosphere-free mag.
const float length = altAzPos.length(); const float length = altAzPos.length();
float obs_alt_deg=180.f/M_PI*std::asin(altAzPos[2]/length); float obs_alt_deg=180.f/M_PI*std::asin(altAzPos[2]/length);
if (obs_alt_deg > 0.22879f) if (obs_alt_deg > 0.22879f)
{ {
 End of changes. 6 change blocks. 
19 lines changed or deleted 30 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/