StelObserver.cpp   StelObserver.cpp 
skipping to change at line 52 skipping to change at line 52
void computeAverage(double f1); void computeAverage(double f1);
private: private:
void setRot(const Vec3d &r); void setRot(const Vec3d &r);
static Vec3d getRot(const Planet* p); static Vec3d getRot(const Planet* p);
PlanetP dest; PlanetP dest;
const QString orig_name; const QString orig_name;
const QString orig_name_i18n; const QString orig_name_i18n;
}; };
ArtificialPlanet::ArtificialPlanet(const PlanetP& orig) : ArtificialPlanet::ArtificialPlanet(const PlanetP& orig) :
Planet("", 0, 0, 0, Vec3f(0,0,0), 0, "", "", NULL, NULL, 0, Planet("art", 0, 0, Vec3f(0,0,0), 0, 0, "", "", "", Q_NULLPT
false, true, false, true, ""), dest(0), R, Q_NULLPTR, Q_NULLPTR, false, true, false, true, "artificial"),
orig_name(orig->getEnglishName()), orig_name_i18n(orig->getN dest(Q_NULLPTR), orig_name(orig->getEnglishName()), orig_nam
ameI18n()) e_i18n(orig->getNameI18n())
{ {
// set parent = sun: // set parent = sun:
if (orig->getParent()) if (orig->getParent())
{ {
parent = orig->getParent(); parent = orig->getParent();
while (parent->getParent()) while (parent->getParent())
parent = parent->getParent(); parent = parent->getParent();
} }
else else
{ {
skipping to change at line 169 skipping to change at line 169
setRot(a1*f1 + a2*f2); setRot(a1*f1 + a2*f2);
// rotation offset // rotation offset
re.offset = f1*re.offset + f2*dest->getRotationElements().offset; re.offset = f1*re.offset + f2*dest->getRotationElements().offset;
} }
StelObserver::StelObserver(const StelLocation &loc) : currentLocation(loc) StelObserver::StelObserver(const StelLocation &loc) : currentLocation(loc)
{ {
SolarSystem* ssystem = GETSTELMODULE(SolarSystem); SolarSystem* ssystem = GETSTELMODULE(SolarSystem);
planet = ssystem->searchByEnglishName(loc.planetName); planet = ssystem->searchByEnglishName(loc.planetName);
if (planet==NULL) if (planet==Q_NULLPTR)
{ {
qWarning() << "Can't create StelObserver on planet " + loc.p lanetName + " because it is unknown. Use Earth as default."; qWarning() << "Can't create StelObserver on planet " + loc.p lanetName + " because it is unknown. Use Earth as default.";
planet=ssystem->getEarth(); planet=ssystem->getEarth();
} }
} }
StelObserver::~StelObserver() StelObserver::~StelObserver()
{ {
} }
skipping to change at line 192 skipping to change at line 192
Q_ASSERT(planet); Q_ASSERT(planet);
return planet; return planet;
} }
Vec3d StelObserver::getCenterVsop87Pos(void) const Vec3d StelObserver::getCenterVsop87Pos(void) const
{ {
return getHomePlanet()->getHeliocentricEclipticPos(); return getHomePlanet()->getHeliocentricEclipticPos();
} }
// Used to approximate solution with assuming a spherical planet. // Used to approximate solution with assuming a spherical planet.
// Since V0.14, following Meeus, Astr. Alg. 2nd ed, Ch.11. // 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.)
double StelObserver::getDistanceFromCenter(void) const double StelObserver::getDistanceFromCenter(void) const
{ {
if (getHomePlanet()->getRadius()==0.0) // the transitional Artificia lPlanet od SpaceShipObserver has this if (getHomePlanet()->getRadius()==0.0) // the transitional Artificia lPlanet or SpaceShipObserver has this
return currentLocation.altitude/(1000*AU); return currentLocation.altitude/(1000*AU);
double a=getHomePlanet()->getRadius(); const double a=getHomePlanet()->getRadius();
double bByA = getHomePlanet()->getOneMinusOblateness(); // b/a; const double bByA = getHomePlanet()->getOneMinusOblateness(); // b/a
;
if (fabs(currentLocation.latitude)>=89.9) // avoid tan(90) issues. if (fabs(currentLocation.latitude)>=89.9) // avoid tan(90) issues.
return a * bByA; return a * bByA;
double latRad=currentLocation.latitude*(M_PI/180.0); const double latRad=currentLocation.latitude*(M_PI/180.0);
double u = atan( bByA * tan(latRad)); const double u = atan( bByA * tan(latRad));
// qDebug() << "getDistanceFromCenter: a=" << a*AU << "b/a=" << bByA << "b=" << bByA*a *AU << "latRad=" << latRad << "u=" << u; // qDebug() << "getDistanceFromCenter: a=" << a*AU << "b/a=" << bByA << "b=" << bByA*a *AU << "latRad=" << latRad << "u=" << u;
Q_ASSERT(fabs(u)<= fabs(latRad)); Q_ASSERT(fabs(u)<= fabs(latRad));
double altFix=(currentLocation.altitude/(1000.0*AU)) / a; const double altFix = currentLocation.altitude/(1000.0*AU*a);
double rhoSinPhiPrime= bByA * sin(u) + altFix*sin(latRad); const double rhoSinPhiPrime= bByA * sin(u) + altFix*sin(latRad);
double rhoCosPhiPrime= cos(u) + altFix*cos(latRad); //double rhoCosPhiPrime= bByA * cos(u) + altFix*cos(latRad); // WARN
ING! bByA is not in the book!!! THIS IS A TEST!
const double rhoCosPhiPrime= cos(u) + altFix*cos(latRad);
double rho = sqrt(rhoSinPhiPrime*rhoSinPhiPrime+rhoCosPhiPrime*rhoCo sPhiPrime); const double rho = sqrt(rhoSinPhiPrime*rhoSinPhiPrime+rhoCosPhiPrime *rhoCosPhiPrime);
return rho*a; return rho*a;
} }
// Used to approximate solution with assuming a spherical planet.
// Since V0.14, following Meeus, Astr. Alg. 2nd ed, Ch.11.
// Since V0.16, we can produce the usual offset values plus geocentric lati
tude phi'.
Vec3d StelObserver::getTopographicOffsetFromCenter(void) const
{
if (getHomePlanet()->getRadius()==0.0) // the transitional Artificia
lPlanet or SpaceShipObserver has this
return currentLocation.altitude/(1000*AU);
const double a=getHomePlanet()->getRadius();
const double bByA = getHomePlanet()->getOneMinusOblateness(); // b/a
;
if (fabs(currentLocation.latitude)>=89.9) // avoid tan(90) issues.
return a * bByA;
const double latRad=currentLocation.latitude*(M_PI/180.0);
const double u = atan( bByA * tan(latRad));
// qDebug() << "getDistanceFromCenter: a=" << a*AU << "b/a=" << bByA
<< "b=" << bByA*a *AU << "latRad=" << latRad << "u=" << u;
Q_ASSERT(fabs(u)<= fabs(latRad));
const double altFix = currentLocation.altitude/(1000.0*AU*a);
const double rhoSinPhiPrime= bByA * sin(u) + altFix*sin(latRad);
const double rhoCosPhiPrime= cos(u) + altFix*cos(latRad);
const double rho = sqrt(rhoSinPhiPrime*rhoSinPhiPrime+rhoCosPhiPrime
*rhoCosPhiPrime);
//return rho*a;
double phiPrime=asin(rhoSinPhiPrime/rho);
return Vec3d(rhoCosPhiPrime*a, rhoSinPhiPrime*a, phiPrime);
}
// For Earth we require JD, for other planets JDE to describe rotation! // For Earth we require JD, for other planets JDE to describe rotation!
Mat4d StelObserver::getRotAltAzToEquatorial(double JD, double JDE) const Mat4d StelObserver::getRotAltAzToEquatorial(double JD, double JDE) const
{ {
double lat = currentLocation.latitude; double lat = currentLocation.latitude;
// TODO: Figure out how to keep continuity in sky as we reach poles // TODO: Figure out how to keep continuity in sky as we reach poles
// otherwise sky jumps in rotation when reach poles in equatorial mo de // otherwise sky jumps in rotation when reach poles in equatorial mo de
// This is a kludge // This is a kludge
// GZ: Actually, why would that be? Lat should be clamped elsewhere. Added tests to track down problems in other locations. // GZ: Actually, why would that be? Lat should be clamped elsewhere. Added tests to track down problems in other locations.
Q_ASSERT(lat <= 90.0); Q_ASSERT(lat <= 90.0);
Q_ASSERT(lat >= -90.0); Q_ASSERT(lat >= -90.0);
skipping to change at line 239 skipping to change at line 269
return Mat4d::zrotation((getHomePlanet()->getSiderealTime(JD, JDE)+c urrentLocation.longitude)*M_PI/180.) return Mat4d::zrotation((getHomePlanet()->getSiderealTime(JD, JDE)+c urrentLocation.longitude)*M_PI/180.)
* Mat4d::yrotation((90.-lat)*M_PI/180.); * Mat4d::yrotation((90.-lat)*M_PI/180.);
} }
Mat4d StelObserver::getRotEquatorialToVsop87(void) const Mat4d StelObserver::getRotEquatorialToVsop87(void) const
{ {
return getHomePlanet()->getRotEquatorialToVsop87(); return getHomePlanet()->getRotEquatorialToVsop87();
} }
SpaceShipObserver::SpaceShipObserver(const StelLocation& startLoc, const St elLocation& target, double atransitSeconds, double atimeToGo) : StelObserve r(startLoc), SpaceShipObserver::SpaceShipObserver(const StelLocation& startLoc, const St elLocation& target, double atransitSeconds, double atimeToGo) : StelObserve r(startLoc),
moveStartLocation(startLoc), moveTargetLocation(target), art ificialPlanet(NULL), timeToGo(atimeToGo), transitSeconds(atransitSeconds) moveStartLocation(startLoc), moveTargetLocation(target), art ificialPlanet(Q_NULLPTR), timeToGo(atimeToGo), transitSeconds(atransitSecon ds)
{ {
if(timeToGo<0.0) if(timeToGo<0.0)
timeToGo = transitSeconds; timeToGo = transitSeconds;
SolarSystem* ssystem = GETSTELMODULE(SolarSystem); SolarSystem* ssystem = GETSTELMODULE(SolarSystem);
PlanetP targetPlanet = ssystem->searchByEnglishName(moveTargetLocati on.planetName); PlanetP targetPlanet = ssystem->searchByEnglishName(moveTargetLocati on.planetName);
if (moveStartLocation.planetName!=moveTargetLocation.planetName) if (moveStartLocation.planetName!=moveTargetLocation.planetName)
{ {
PlanetP startPlanet = ssystem->searchByEnglishName(moveStart Location.planetName); PlanetP startPlanet = ssystem->searchByEnglishName(moveStart Location.planetName);
if (startPlanet.isNull() || targetPlanet.isNull()) if (startPlanet.isNull() || targetPlanet.isNull())
{ {
qWarning() << "Can't move from planet " + moveStartL ocation.planetName + " to planet " + moveTargetLocation.planetName + " beca use it is unknown"; qWarning() << "Can't move from planet " + moveStartL ocation.planetName + " to planet " + moveTargetLocation.planetName + " beca use it is unknown";
timeToGo = -1.; // Will abort properly the move timeToGo = -1.; // Will abort properly the move
if (targetPlanet==NULL) if (targetPlanet==Q_NULLPTR)
{ {
// Stay at the same position as a failover // Stay at the same position as a failover
moveTargetLocation = moveStartLocation; moveTargetLocation = moveStartLocation;
} }
return; return;
} }
ArtificialPlanet* artPlanet = new ArtificialPlanet(startPlan et); ArtificialPlanet* artPlanet = new ArtificialPlanet(startPlan et);
artPlanet->setDest(targetPlanet); artPlanet->setDest(targetPlanet);
artificialPlanet = QSharedPointer<Planet>(artPlanet); artificialPlanet = QSharedPointer<Planet>(artPlanet);
skipping to change at line 326 skipping to change at line 356
const double moveToMult = 1.-(timeToGo/transitSeconds); const double moveToMult = 1.-(timeToGo/transitSeconds);
currentLocation.latitude = moveStartLocation.latitude - move ToMult*(moveStartLocation.latitude-moveTargetLocation.latitude); currentLocation.latitude = moveStartLocation.latitude - move ToMult*(moveStartLocation.latitude-moveTargetLocation.latitude);
currentLocation.longitude = moveStartLocation.longitude - mo veToMult*(moveStartLocation.longitude-moveTargetLocation.longitude); currentLocation.longitude = moveStartLocation.longitude - mo veToMult*(moveStartLocation.longitude-moveTargetLocation.longitude);
currentLocation.altitude = int(moveStartLocation.altitude - moveToMult*(moveStartLocation.altitude-moveTargetLocation.altitude)); currentLocation.altitude = int(moveStartLocation.altitude - moveToMult*(moveStartLocation.altitude-moveTargetLocation.altitude));
} }
return true; return true;
} }
const QSharedPointer<Planet> SpaceShipObserver::getHomePlanet() const const QSharedPointer<Planet> SpaceShipObserver::getHomePlanet() const
{ {
return (isObserverLifeOver() || artificialPlanet==NULL) ? planet : artificialPlanet; return (isObserverLifeOver() || artificialPlanet==Q_NULLPTR) ? plan et : artificialPlanet;
} }
 End of changes. 13 change blocks. 
18 lines changed or deleted 55 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/