~toshaevil/stellarium/new-keybindings

« back to all changes in this revision

Viewing changes to src/core/RefractionExtinction.cpp

  • Committer: toshaevil
  • Date: 2012-09-08 14:01:04 UTC
  • mfrom: (5299.1.299 trunk)
  • Revision ID: toshaevil@gmail.com-20120908140104-lcw0qez8tn347z3n
merge with trunk; fix little bug with adding telescope plugins shortcuts

Show diffs side-by-side

added added

removed removed

Lines of Context:
230
230
 
231
231
void Refraction::forward(Vec3f& altAzPos) const
232
232
{
233
 
        altAzPos.transfo4d(preTransfoMatf);
234
 
        const float length = altAzPos.length();
235
 
        float geom_alt_deg=180.f/M_PI*std::asin(altAzPos[2]/length);
236
 
        if (geom_alt_deg > Refraction::MIN_GEO_ALTITUDE_DEG_F)
 
233
        // Using doubles internally to avoid jitter.
 
234
        // (This affects planet drawing - which is done using floats, 
 
235
        // as doubles are unsupported/slow on GPUs)
 
236
        Vec3d altAzPosD(altAzPos[0], altAzPos[1], altAzPos[2]);
 
237
        altAzPosD.transfo4d(preTransfoMat);
 
238
        const double length = altAzPosD.length();
 
239
        double geom_alt_deg=180./M_PI*std::asin(altAzPosD[2]/length);
 
240
        if (geom_alt_deg > Refraction::MIN_GEO_ALTITUDE_DEG)
237
241
        {
238
242
                // refraction from Saemundsson, S&T1986 p70 / in Meeus, Astr.Alg.
239
 
                float r=press_temp_corr_Saemundson / std::tan((geom_alt_deg+10.3f/(geom_alt_deg+5.11f))*M_PI/180.f) + 0.0019279f;
 
243
                double r=press_temp_corr_Saemundson / 
 
244
                        std::tan((geom_alt_deg+10.3/(geom_alt_deg+5.11))*M_PI/180.) + 0.0019279;
240
245
                geom_alt_deg += r;
241
 
                if (geom_alt_deg > 90.f) geom_alt_deg=90.f; // SAFETY
242
 
                altAzPos[2]=std::sin(geom_alt_deg*M_PI/180.f)*length;
 
246
                if (geom_alt_deg > 90.) geom_alt_deg=90.; // SAFETY
 
247
                altAzPosD[2]=std::sin(geom_alt_deg*M_PI/180.)*length;
243
248
        }
244
 
        else if(geom_alt_deg>Refraction::MIN_GEO_ALTITUDE_DEG_F-Refraction::TRANSITION_WIDTH_GEO_DEG_F)
 
249
        else if(geom_alt_deg>Refraction::MIN_GEO_ALTITUDE_DEG-Refraction::TRANSITION_WIDTH_GEO_DEG)
245
250
        {
246
 
                // Avoids the jump below -5 by interpolating linearly between MIN_GEO_ALTITUDE_DEG_F and bottom of transition zone
247
 
                float r_m5=press_temp_corr_Saemundson / std::tan((Refraction::MIN_GEO_ALTITUDE_DEG_F+10.3f/(Refraction::MIN_GEO_ALTITUDE_DEG_F+5.11f))*M_PI/180.f) + 0.0019279f;
248
 
                geom_alt_deg += r_m5*(geom_alt_deg-(Refraction::MIN_GEO_ALTITUDE_DEG_F-Refraction::TRANSITION_WIDTH_GEO_DEG_F))/Refraction::TRANSITION_WIDTH_GEO_DEG_F;
249
 
                altAzPos[2]=std::sin(geom_alt_deg*M_PI/180.)*length;
 
251
                // Avoids the jump below -5 by interpolating linearly between MIN_GEO_ALTITUDE_DEG and bottom of transition zone
 
252
                double r_m5=press_temp_corr_Saemundson /
 
253
                          std::tan((Refraction::MIN_GEO_ALTITUDE_DEG+10.3/
 
254
                                    (Refraction::MIN_GEO_ALTITUDE_DEG+5.11))*M_PI/180.) + 0.0019279;
 
255
                geom_alt_deg += 
 
256
                        r_m5*(geom_alt_deg-(Refraction::MIN_GEO_ALTITUDE_DEG-
 
257
                                            Refraction::TRANSITION_WIDTH_GEO_DEG))
 
258
                        /Refraction::TRANSITION_WIDTH_GEO_DEG;
 
259
                altAzPosD[2]=std::sin(geom_alt_deg*M_PI/180.)*length;
250
260
        }
251
 
        altAzPos.transfo4d(postTransfoMatf);
 
261
        altAzPosD.transfo4d(postTransfoMat);
 
262
 
 
263
        altAzPos = Vec3f(altAzPosD[0], altAzPosD[1], altAzPosD[2]);
252
264
}
253
265
 
254
266
void Refraction::backward(Vec3f& altAzPos) const