Home · All Namespaces · All Classes · Functions · Coding Style · Plugins · File Structure

modules/Orbit.hpp

00001 // orbit.h
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // CometOrbit: Copyright (C) 2007,2008 Johannes Gajdosik
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 
00012 #ifndef _ORBIT_HPP_
00013 #define _ORBIT_HPP_
00014 
00015 #include "VecMath.hpp"
00016 
00017 class OrbitSampleProc;
00018 
00021 class Orbit
00022 {
00023 public:
00024     Orbit(void) {}
00025     virtual ~Orbit(void) {}
00026 //    virtual Vec3d positionAtTime(double) const = 0;
00027 //    virtual double getPeriod() const = 0;
00028 //    virtual double getBoundingRadius() const = 0;
00029 //    virtual void sample(double, double, int, OrbitSampleProc&) const = 0;
00030 private:
00031   Orbit(const Orbit&);
00032   const Orbit &operator=(const Orbit&);
00033 };
00034 
00035 
00036 class EllipticalOrbit : public Orbit
00037 {
00038 public:
00039     EllipticalOrbit(double pericenterDistance,
00040                     double eccentricity,
00041                     double inclination,
00042                     double ascendingNode,
00043                     double argOfPeriapsis,
00044                     double meanAnomalyAtEpoch,
00045                     double period,
00046                     double epoch, // = 2451545.0,
00047                     double parentRotObliquity, // = 0.0,
00048                     double parentRotAscendingnode, // = 0.0
00049                     double parentRotJ2000Longitude  // = 0.0
00050                     );
00051 
00052     // Compute the orbit for a specified Julian date and return a "stellarium compliant" function
00053 //    void positionAtTime(double JD, double * X, double * Y, double * Z) const;
00054 //    void positionAtTimev(double JD, double* v);
00055 
00056       // Compute position for a specified Julian date and return coordinates
00057       // given in "dynamical equinox and ecliptic J2000"
00058       // which is the reference frame for VSOP87
00059       // In order to rotate to VSOP87
00060       // parentRotObliquity and parentRotAscendingnode must be supplied.
00061     void positionAtTimevInVSOP87Coordinates(double JD, double* v) const;
00062 
00063       // Original one
00064     Vec3d positionAtTime(double) const;
00065     double getPeriod() const;
00066     double getBoundingRadius() const;
00067     virtual void sample(double, double, int, OrbitSampleProc&) const;
00068 
00069 private:
00070     double eccentricAnomaly(double) const;
00071     Vec3d positionAtE(double) const;
00072 
00073     double pericenterDistance;
00074     double eccentricity;
00075     double inclination;
00076     double ascendingNode;
00077     double argOfPeriapsis;
00078     double meanAnomalyAtEpoch;
00079     double period;
00080     double epoch;
00081     double rotateToVsop87[9];
00082 };
00083 
00084 
00085 class CometOrbit : public Orbit {
00086 public:
00087   CometOrbit(double pericenterDistance,
00088              double eccentricity,
00089              double inclination,
00090              double ascendingNode,
00091              double argOfPerhelion,
00092              double timeAtPerihelion,
00093              double meanMotion,
00094              double parentRotObliquity,
00095              double parentRotAscendingnode,
00096              double parentRotJ2000Longitude);
00097 
00098     // Compute the orbit for a specified Julian date and return a "stellarium compliant" function
00099   void positionAtTimevInVSOP87Coordinates(double JD, double* v) const;
00100 private:
00101   const double q;
00102   const double e;
00103   const double i;
00104   const double Om;
00105   const double o;
00106   const double t0;
00107   const double n;
00108   double rotateToVsop87[9];
00109 };
00110 
00111 
00112 class OrbitSampleProc
00113 {
00114  public:
00115     virtual ~OrbitSampleProc() {;}
00116     virtual void sample(const Vec3d&) = 0;
00117 };
00118 
00119 
00120 
00121 // Custom orbit classes should be derived from CachingOrbit.  The custom
00122 // orbits can be expensive to compute, with more than 50 periodic terms.
00123 // Celestia may need require position of a Planet more than once per frame; in
00124 // order to avoid redundant calculation, the CachingOrbit class saves the
00125 // result of the last calculation and uses it if the time matches the cached
00126 // time.
00127 class CachingOrbit : public Orbit
00128 {
00129 public:
00130     CachingOrbit() : lastTime(1.0e-30) {};
00131 
00132     virtual Vec3d computePosition(double jd) const = 0;
00133     virtual double getPeriod() const = 0;
00134     virtual double getBoundingRadius() const = 0;
00135 
00136     Vec3d positionAtTime(double jd) const;
00137 
00138     virtual void sample(double, double, int, OrbitSampleProc& proc) const;
00139 
00140 private:
00141     mutable Vec3d lastPosition;
00142     mutable double lastTime;
00143 };
00144 
00145 
00146 
00147 #endif // _ORBIT_HPP_

Generated on Mon Mar 9 16:16:16 2009 for Stellarium by  doxygen 1.5.5