Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

orbit.h

Go to the documentation of this file.
00001 // orbit.h
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #ifndef _ORBIT_H_
00011 #define _ORBIT_H_
00012 
00013 #include <celmath/vecmath.h>
00014 
00015 
00016 class OrbitSampleProc;
00017 
00018 class Orbit
00019 {
00020 public:
00021     virtual Point3d positionAtTime(double) const = 0;
00022     virtual double getPeriod() const = 0;
00023     virtual double getBoundingRadius() const = 0;
00024     virtual void sample(double, double, int, OrbitSampleProc&) const = 0;
00025     virtual bool isPeriodic() const { return true; };
00026 
00027     // Return the time range over which the orbit is valid; if the orbit
00028     // is always valid, begin and end should be equal.
00029     virtual void getValidRange(double& begin, double& end) const
00030         { begin = 0.0; end = 0.0; };
00031 };
00032 
00033 
00034 class EllipticalOrbit : public Orbit
00035 {
00036 public:
00037     EllipticalOrbit(double, double, double, double, double, double, double,
00038                     double _epoch = 2451545.0);
00039 
00040     // Compute the orbit for a specified Julian date
00041     Point3d positionAtTime(double) const;
00042     double getPeriod() const;
00043     double getBoundingRadius() const;
00044     virtual void sample(double, double, int, OrbitSampleProc&) const;
00045 
00046 private:
00047     double eccentricAnomaly(double) const;
00048     Point3d positionAtE(double) const;
00049 
00050     double pericenterDistance;
00051     double eccentricity;
00052     double inclination;
00053     double ascendingNode;
00054     double argOfPeriapsis;
00055     double meanAnomalyAtEpoch;
00056     double period;
00057     double epoch;
00058 };
00059 
00060 
00061 class OrbitSampleProc
00062 {
00063  public:
00064     virtual void sample(double t, const Point3d&) = 0;
00065 };
00066 
00067 
00068 
00076 class CachingOrbit : public Orbit
00077 {
00078 public:
00079     CachingOrbit() : lastTime(1.0e-30) {};
00080 
00081     virtual Point3d computePosition(double jd) const = 0;
00082     virtual double getPeriod() const = 0;
00083     virtual double getBoundingRadius() const = 0;
00084 
00085     Point3d positionAtTime(double jd) const;
00086 
00087     virtual void sample(double, double, int, OrbitSampleProc& proc) const;
00088 
00089 private:
00090     mutable Point3d lastPosition;
00091     mutable double lastTime;
00092 };
00093 
00094 
00101 class MixedOrbit : public Orbit
00102 {
00103  public:
00104     MixedOrbit(Orbit* orbit, double t0, double t1, double mass);
00105     virtual ~MixedOrbit();
00106 
00107     Point3d positionAtTime(double jd) const;
00108     virtual double getPeriod() const;
00109     virtual double getBoundingRadius() const;
00110     virtual void sample(double, double, int, OrbitSampleProc& proc) const;
00111 
00112  private:
00113     Orbit* primary;
00114     EllipticalOrbit* afterApprox;
00115     EllipticalOrbit* beforeApprox;
00116     double begin;
00117     double end;
00118     double boundingRadius;
00119 };
00120 
00121 
00122 class Body;
00123 
00129 class SynchronousOrbit : public Orbit
00130 {
00131  public:
00132     SynchronousOrbit(const Body& _body, const Point3d& _position);
00133     virtual ~SynchronousOrbit();
00134 
00135     Point3d positionAtTime(double jd) const;
00136     virtual double getPeriod() const;
00137     virtual double getBoundingRadius() const;
00138     virtual void sample(double, double, int, OrbitSampleProc& proc) const;
00139 
00140  private:
00141     const Body& body;
00142     Point3d position;
00143 };
00144 
00145 
00146 #endif // _ORBIT_H_

Generated on Sat Jan 14 22:30:28 2006 for Celestia by  doxygen 1.4.1