Observer.cpp   StelObserver.cpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "Observer.hpp" #include "StelObserver.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "Translator.hpp" #include "StelTranslator.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "Navigator.hpp" #include "StelNavigator.hpp"
#include "LocationMgr.hpp" #include "StelLocationMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
#include <QStringList> #include <QStringList>
class ArtificialPlanet : public Planet class ArtificialPlanet : public Planet
{ {
public: public:
ArtificialPlanet(const Planet &orig); ArtificialPlanet(const Planet &orig);
skipping to change at line 50 skipping to change at line 50
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);
const Planet *dest; const Planet *dest;
const QString orig_name; const QString orig_name;
const QString orig_name_i18n; const QString orig_name_i18n;
}; };
ArtificialPlanet::ArtificialPlanet(const Planet &orig) : ArtificialPlanet::ArtificialPlanet(const Planet &orig) :
Planet(0, "", 0, 0, 0, 0, Vec3f(0,0,0), 0, "", "", Planet("", 0, 0, 0, Vec3f(0,0,0), 0, "", "",
posFuncType(), 0, false, true, false), dest(0), posFuncType(), 0, false, true, false), dest(0),
orig_name(orig.getEnglishName()), orig_name_i18n(orig.getNam eI18n()) orig_name(orig.getEnglishName()), orig_name_i18n(orig.getNam eI18n())
{ {
radius = 0; radius = 0;
// 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();
skipping to change at line 79 skipping to change at line 79
} }
void ArtificialPlanet::setDest(const Planet &dest) void ArtificialPlanet::setDest(const Planet &dest)
{ {
ArtificialPlanet::dest = &dest; ArtificialPlanet::dest = &dest;
englishName = QString("%1->%2").arg(orig_name).arg(dest.getEnglishNa me()); englishName = QString("%1->%2").arg(orig_name).arg(dest.getEnglishNa me());
nameI18 = QString("%1->%2").arg(orig_name_i18n).arg(dest.getNameI18n ()); nameI18 = QString("%1->%2").arg(orig_name_i18n).arg(dest.getNameI18n ());
// rotation: // rotation:
const RotationElements &r(dest.getRotationElements()); const RotationElements &r(dest.getRotationElements());
lastJD = StelApp::getInstance().getCore()->getNavigation()->getJDay( ); lastJD = StelApp::getInstance().getCore()->getNavigator()->getJDay() ;
re.offset = r.offset + fmod(re.offset - r.offset + 360.0*( (lastJD-r e.epoch)/re.period - (lastJD-r.epoch)/r.period), 360.0); re.offset = r.offset + fmod(re.offset - r.offset + 360.0*( (lastJD-r e.epoch)/re.period - (lastJD-r.epoch)/r.period), 360.0);
re.epoch = r.epoch; re.epoch = r.epoch;
re.period = r.period; re.period = r.period;
if (re.offset - r.offset < -180.f) re.offset += 360.f; else if (re.offset - r.offset < -180.f) re.offset += 360.f; else
if (re.offset - r.offset > 180.f) re.offset -= 360.f; if (re.offset - r.offset > 180.f) re.offset -= 360.f;
} }
void ArtificialPlanet::setRot(const Vec3d &r) void ArtificialPlanet::setRot(const Vec3d &r)
skipping to change at line 165 skipping to change at line 165
a1[2] -= 2.0*M_PI; a1[2] -= 2.0*M_PI;
else else
if (a1[2]-a2[2] < -M_PI) if (a1[2]-a2[2] < -M_PI)
a1[2] += 2.0*M_PI; a1[2] += 2.0*M_PI;
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;
} }
Observer::Observer(const Location &loc) : currentLocation(loc) StelObserver::StelObserver(const StelLocation &loc) : currentLocation(loc)
{ {
SolarSystem* ssystem = (SolarSystem*)GETSTELMODULE("SolarSystem"); SolarSystem* ssystem = (SolarSystem*)GETSTELMODULE("SolarSystem");
planet = ssystem->searchByEnglishName(loc.planetName); planet = ssystem->searchByEnglishName(loc.planetName);
if (planet==NULL) if (planet==NULL)
{ {
qWarning() << "Can't create Observer on planet " + loc.plane tName + " 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();
} }
} }
Observer::~Observer() StelObserver::~StelObserver()
{ {
} }
Vec3d Observer::getCenterVsop87Pos(void) const Vec3d StelObserver::getCenterVsop87Pos(void) const
{ {
return getHomePlanet()->getHeliocentricEclipticPos(); return getHomePlanet()->getHeliocentricEclipticPos();
} }
double Observer::getDistanceFromCenter(void) const double StelObserver::getDistanceFromCenter(void) const
{ {
return getHomePlanet()->getRadius() + (currentLocation.altitude/(100 0*AU)); return getHomePlanet()->getRadius() + (currentLocation.altitude/(100 0*AU));
} }
Mat4d Observer::getRotLocalToEquatorial(double jd) const Mat4d StelObserver::getRotAltAzToEquatorial(double jd) const
{ {
double lat = currentLocation.latitude; double lat = currentLocation.latitude;
// TODO: Figure out how to keep continuity in sky as reach poles // TODO: Figure out how to keep continuity in sky as 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
if( lat > 89.5 ) lat = 89.5; if( lat > 89.5 ) lat = 89.5;
if( lat < -89.5 ) lat = -89.5; if( lat < -89.5 ) lat = -89.5;
return Mat4d::zrotation((getHomePlanet()->getSiderealTime(jd)+curren tLocation.longitude)*(M_PI/180.)) return Mat4d::zrotation((getHomePlanet()->getSiderealTime(jd)+curren tLocation.longitude)*(M_PI/180.))
* Mat4d::yrotation((90.-lat)*(M_PI/180.)); * Mat4d::yrotation((90.-lat)*(M_PI/180.));
} }
Mat4d Observer::getRotEquatorialToVsop87(void) const Mat4d StelObserver::getRotEquatorialToVsop87(void) const
{ {
return getHomePlanet()->getRotEquatorialToVsop87(); return getHomePlanet()->getRotEquatorialToVsop87();
} }
SpaceShipObserver::SpaceShipObserver(const Location& startLoc, const Locati on& target, double atransitSeconds) : Observer(startLoc), SpaceShipObserver::SpaceShipObserver(const StelLocation& startLoc, const St elLocation& target, double atransitSeconds) : StelObserver(startLoc),
moveStartLocation(startLoc), moveTargetLocation(target), art ificialPlanet(NULL), transitSeconds(atransitSeconds) moveStartLocation(startLoc), moveTargetLocation(target), art ificialPlanet(NULL), transitSeconds(atransitSeconds)
{ {
SolarSystem* ssystem = (SolarSystem*)GETSTELMODULE("SolarSystem"); SolarSystem* ssystem = (SolarSystem*)GETSTELMODULE("SolarSystem");
Planet *targetPlanet = ssystem->searchByEnglishName(moveTargetLocati on.planetName); Planet *targetPlanet = ssystem->searchByEnglishName(moveTargetLocati on.planetName);
if (moveStartLocation.planetName!=moveTargetLocation.planetName) if (moveStartLocation.planetName!=moveTargetLocation.planetName)
{ {
Planet *startPlanet = ssystem->searchByEnglishName(moveStart Location.planetName); Planet *startPlanet = ssystem->searchByEnglishName(moveStart Location.planetName);
if (startPlanet==NULL || targetPlanet==NULL) if (startPlanet==NULL || targetPlanet==NULL)
{ {
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";
 End of changes. 13 change blocks. 
14 lines changed or deleted 14 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/