Stellarium 0.12.0
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · Renderer · File Structure

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 private:
00027   Orbit(const Orbit&);
00028   const Orbit &operator=(const Orbit&);
00029 };
00030 
00031 
00032 class EllipticalOrbit : public Orbit
00033 {
00034 public:
00035     EllipticalOrbit(double pericenterDistance,
00036                     double eccentricity,
00037                     double inclination,
00038                     double ascendingNode,
00039                     double argOfPeriapsis,
00040                     double meanAnomalyAtEpoch,
00041                     double period,
00042                     double epoch, // = 2451545.0,
00043                     double parentRotObliquity, // = 0.0,
00044                     double parentRotAscendingnode, // = 0.0
00045                     double parentRotJ2000Longitude  // = 0.0
00046                     );
00047 
00048     // Compute position for a specified Julian date and return coordinates
00049     // given in "dynamical equinox and ecliptic J2000"
00050     // which is the reference frame for VSOP87
00051     // In order to rotate to VSOP87
00052     // parentRotObliquity and parentRotAscendingnode must be supplied.
00053     void positionAtTimevInVSOP87Coordinates(double JD, double* v) const;
00054 
00055     // Original one
00056     Vec3d positionAtTime(double) const;
00057     double getPeriod() const;
00058     double getBoundingRadius() const;
00059     virtual void sample(double, double, int, OrbitSampleProc&) const;
00060 
00061 private:
00062     double eccentricAnomaly(double) const;
00063     Vec3d positionAtE(double) const;
00064 
00065     double pericenterDistance;
00066     double eccentricity;
00067     double inclination;
00068     double ascendingNode;
00069     double argOfPeriapsis;
00070     double meanAnomalyAtEpoch;
00071     double period;
00072     double epoch;
00073     double rotateToVsop87[9];
00074 };
00075 
00076 
00077 class CometOrbit : public Orbit {
00078 public:
00079   CometOrbit(double pericenterDistance,
00080              double eccentricity,
00081              double inclination,
00082              double ascendingNode,
00083              double argOfPerhelion,
00084              double timeAtPerihelion,
00085              double meanMotion,
00086              double parentRotObliquity,
00087              double parentRotAscendingnode,
00088              double parentRotJ2000Longitude);
00089 
00090     // Compute the orbit for a specified Julian date and return a "stellarium compliant" function
00091   void positionAtTimevInVSOP87Coordinates(double JD, double* v) const;
00092 private:
00093   const double q;
00094   const double e;
00095   const double i;
00096   const double Om;
00097   const double o;
00098   const double t0;
00099   const double n;
00100   double rotateToVsop87[9];
00101 };
00102 
00103 
00104 class OrbitSampleProc
00105 {
00106  public:
00107     virtual ~OrbitSampleProc() {;}
00108     virtual void sample(const Vec3d&) = 0;
00109 };
00110 
00111 
00112 
00113 // Custom orbit classes should be derived from CachingOrbit.  The custom
00114 // orbits can be expensive to compute, with more than 50 periodic terms.
00115 // Celestia may need require position of a Planet more than once per frame; in
00116 // order to avoid redundant calculation, the CachingOrbit class saves the
00117 // result of the last calculation and uses it if the time matches the cached
00118 // time.
00119 class CachingOrbit : public Orbit
00120 {
00121 public:
00122     CachingOrbit() : lastTime(1.0e-30) {};
00123 
00124     virtual Vec3d computePosition(double jd) const = 0;
00125     virtual double getPeriod() const = 0;
00126     virtual double getBoundingRadius() const = 0;
00127 
00128     Vec3d positionAtTime(double jd) const;
00129 
00130     virtual void sample(double, double, int, OrbitSampleProc& proc) const;
00131 
00132 private:
00133     mutable Vec3d lastPosition;
00134     mutable double lastTime;
00135 };
00136 
00137 
00138 
00139 #endif // _ORBIT_HPP_
Generated on Thu Jan 31 14:05:39 2013 for Stellarium by  doxygen 1.6.3