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())
55
55
// set parent = sun:
56
56
if (orig->getParent())
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
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);
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;
204
204
if (fabs(currentLocation.latitude)>=89.9) // avoid tan(90) issues.
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;
213
double rhoSinPhiPrime= bByA * sin(u) + altFix*sin(latRad);
214
double rhoCosPhiPrime= cos(u) + altFix*cos(latRad);
216
double rho = sqrt(rhoSinPhiPrime*rhoSinPhiPrime+rhoCosPhiPrime*rhoCosPhiPrime);
211
const double altFix = currentLocation.altitude/(1000.0*AU*a);
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);
217
const double rho = sqrt(rhoSinPhiPrime*rhoSinPhiPrime+rhoCosPhiPrime*rhoCosPhiPrime);
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
226
if (getHomePlanet()->getRadius()==0.0) // the transitional ArtificialPlanet or SpaceShipObserver has this
227
return currentLocation.altitude/(1000*AU);
229
const double a=getHomePlanet()->getRadius();
230
const double bByA = getHomePlanet()->getOneMinusOblateness(); // b/a;
232
if (fabs(currentLocation.latitude)>=89.9) // avoid tan(90) issues.
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);
241
const double rhoSinPhiPrime= bByA * sin(u) + altFix*sin(latRad);
242
const double rhoCosPhiPrime= cos(u) + altFix*cos(latRad);
244
const double rho = sqrt(rhoSinPhiPrime*rhoSinPhiPrime+rhoCosPhiPrime*rhoCosPhiPrime);
246
double phiPrime=asin(rhoSinPhiPrime/rho);
247
return Vec3d(rhoCosPhiPrime*a, rhoSinPhiPrime*a, phiPrime);
220
250
// For Earth we require JD, for other planets JDE to describe rotation!
221
251
Mat4d StelObserver::getRotAltAzToEquatorial(double JD, double JDE) const