~georg-zotti/stellarium/gz_AtmosphereTweaks

« back to all changes in this revision

Viewing changes to src/core/StelObserver.cpp

  • Committer: Georg Zotti
  • Date: 2017-06-21 14:17:04 UTC
  • mfrom: (8115.1.1476 trunk)
  • Revision ID: georg.zotti@univie.ac.at-20170621141704-0peqcgya7kixg71f
merge-in trunk r9591 (v0.16.0)

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
};
50
50
 
51
51
ArtificialPlanet::ArtificialPlanet(const PlanetP& orig) :
52
 
                Planet("", 0, 0, Vec3f(0,0,0), 0, 0, "", "", "", Q_NULLPTR, Q_NULLPTR, 0, false, true, false, true, ""), dest(0),
53
 
                orig_name(orig->getEnglishName()), orig_name_i18n(orig->getNameI18n())
 
52
                Planet("art", 0, 0, Vec3f(0,0,0), 0, 0, "", "", "", Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, false, true, false, true, "artificial"),
 
53
                dest(Q_NULLPTR), orig_name(orig->getEnglishName()), orig_name_i18n(orig->getNameI18n())
54
54
{
55
55
        // set parent = sun:
56
56
        if (orig->getParent())
192
192
}
193
193
 
194
194
// Used to approximate solution with assuming a spherical planet.
195
 
// Since V0.14, following Meeus, Astr. Alg. 2nd ed, Ch.11.
 
195
// Since V0.14, we follow Meeus, Astr. Alg. 2nd ed, Ch.11., but used offset rho in a wrong way. (offset angle phi in distance rho.)
196
196
double StelObserver::getDistanceFromCenter(void) const
197
197
{
198
 
        if (getHomePlanet()->getRadius()==0.0) // the transitional ArtificialPlanet od SpaceShipObserver has this
 
198
        if (getHomePlanet()->getRadius()==0.0) // the transitional ArtificialPlanet or SpaceShipObserver has this
199
199
                return currentLocation.altitude/(1000*AU);
200
200
 
201
 
        double a=getHomePlanet()->getRadius();
202
 
        double bByA = getHomePlanet()->getOneMinusOblateness(); // b/a;
 
201
        const double a=getHomePlanet()->getRadius();
 
202
        const double bByA = getHomePlanet()->getOneMinusOblateness(); // b/a;
203
203
 
204
204
        if (fabs(currentLocation.latitude)>=89.9) // avoid tan(90) issues.
205
205
                return a * bByA;
206
206
 
207
 
        double latRad=currentLocation.latitude*(M_PI/180.0);
208
 
        double u = atan( bByA * tan(latRad));
 
207
        const double latRad=currentLocation.latitude*(M_PI/180.0);
 
208
        const double u = atan( bByA * tan(latRad));
209
209
        // qDebug() << "getDistanceFromCenter: a=" << a*AU << "b/a=" << bByA << "b=" << bByA*a *AU  << "latRad=" << latRad << "u=" << u;
210
210
        Q_ASSERT(fabs(u)<= fabs(latRad));
211
 
        double altFix=(currentLocation.altitude/(1000.0*AU)) / a;
212
 
 
213
 
        double rhoSinPhiPrime= bByA * sin(u) + altFix*sin(latRad);
214
 
        double rhoCosPhiPrime= cos(u) + altFix*cos(latRad);
215
 
 
216
 
        double rho = sqrt(rhoSinPhiPrime*rhoSinPhiPrime+rhoCosPhiPrime*rhoCosPhiPrime);
 
211
        const double altFix = currentLocation.altitude/(1000.0*AU*a);
 
212
 
 
213
        const double rhoSinPhiPrime= bByA * sin(u) + altFix*sin(latRad);
 
214
        //double rhoCosPhiPrime= bByA * cos(u) + altFix*cos(latRad); // WARNING! bByA is not in the book!!! THIS IS A TEST!
 
215
        const double rhoCosPhiPrime=        cos(u) + altFix*cos(latRad);
 
216
 
 
217
        const double rho = sqrt(rhoSinPhiPrime*rhoSinPhiPrime+rhoCosPhiPrime*rhoCosPhiPrime);
217
218
        return rho*a;
218
219
}
219
220
 
 
221
// Used to approximate solution with assuming a spherical planet.
 
222
// Since V0.14, following Meeus, Astr. Alg. 2nd ed, Ch.11.
 
223
// Since V0.16, we can produce the usual offset values plus geocentric latitude phi'.
 
224
Vec3d StelObserver::getTopographicOffsetFromCenter(void) const
 
225
{
 
226
        if (getHomePlanet()->getRadius()==0.0) // the transitional ArtificialPlanet or SpaceShipObserver has this
 
227
                return currentLocation.altitude/(1000*AU);
 
228
 
 
229
        const double a=getHomePlanet()->getRadius();
 
230
        const double bByA = getHomePlanet()->getOneMinusOblateness(); // b/a;
 
231
 
 
232
        if (fabs(currentLocation.latitude)>=89.9) // avoid tan(90) issues.
 
233
                return a * bByA;
 
234
 
 
235
        const double latRad=currentLocation.latitude*(M_PI/180.0);
 
236
        const double u = atan( bByA * tan(latRad));
 
237
        // qDebug() << "getDistanceFromCenter: a=" << a*AU << "b/a=" << bByA << "b=" << bByA*a *AU  << "latRad=" << latRad << "u=" << u;
 
238
        Q_ASSERT(fabs(u)<= fabs(latRad));
 
239
        const double altFix = currentLocation.altitude/(1000.0*AU*a);
 
240
 
 
241
        const double rhoSinPhiPrime= bByA * sin(u) + altFix*sin(latRad);
 
242
        const double rhoCosPhiPrime=        cos(u) + altFix*cos(latRad);
 
243
 
 
244
        const double rho = sqrt(rhoSinPhiPrime*rhoSinPhiPrime+rhoCosPhiPrime*rhoCosPhiPrime);
 
245
        //return rho*a;
 
246
        double phiPrime=asin(rhoSinPhiPrime/rho);
 
247
        return Vec3d(rhoCosPhiPrime*a, rhoSinPhiPrime*a, phiPrime);
 
248
}
 
249
 
220
250
// For Earth we require JD, for other planets JDE to describe rotation!
221
251
Mat4d StelObserver::getRotAltAzToEquatorial(double JD, double JDE) const
222
252
{