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

EllipticalOrbit Class Reference

#include <orbit.h>

Inheritance diagram for EllipticalOrbit:

Inheritance graph
Collaboration diagram for EllipticalOrbit:

Collaboration graph
List of all members.

Public Member Functions

 EllipticalOrbit (double, double, double, double, double, double, double, double _epoch=2451545.0)
double getBoundingRadius () const
double getPeriod () const
Point3d positionAtTime (double) const
virtual void sample (double, double, int, OrbitSampleProc &) const

Private Member Functions

double eccentricAnomaly (double) const
Point3d positionAtE (double) const

Private Attributes

double argOfPeriapsis
double ascendingNode
double eccentricity
double epoch
double inclination
double meanAnomalyAtEpoch
double pericenterDistance
double period

Constructor & Destructor Documentation

EllipticalOrbit::EllipticalOrbit double  ,
double  ,
double  ,
double  ,
double  ,
double  ,
double  ,
double  _epoch = 2451545.0
 

Definition at line 23 of file orbit.cpp.

00030                                                 :
00031     pericenterDistance(_pericenterDistance),
00032     eccentricity(_eccentricity),
00033     inclination(_inclination),
00034     ascendingNode(_ascendingNode),
00035     argOfPeriapsis(_argOfPeriapsis),
00036     meanAnomalyAtEpoch(_meanAnomalyAtEpoch),
00037     period(_period),
00038     epoch(_epoch)
00039 {
00040 }


Member Function Documentation

double EllipticalOrbit::eccentricAnomaly double   )  const [private]
 

Definition at line 118 of file orbit.cpp.

References eccentricity, log(), sign(), sin(), and solve_iteration_fixed().

Referenced by positionAtTime().

00119 {
00120     if (eccentricity == 0.0)
00121     {
00122         // Circular orbit
00123         return M;
00124     }
00125     else if (eccentricity < 0.2)
00126     {
00127         // Low eccentricity, so use the standard iteration technique
00128         Solution sol = solve_iteration_fixed(SolveKeplerFunc1(eccentricity, M), M, 5);
00129         return sol.first;
00130     }
00131     else if (eccentricity < 0.9)
00132     {
00133         // Higher eccentricity elliptical orbit; use a more complex but
00134         // much faster converging iteration.
00135         Solution sol = solve_iteration_fixed(SolveKeplerFunc2(eccentricity, M), M, 6);
00136         // Debugging
00137         // printf("ecc: %f, error: %f mas\n",
00138         //        eccentricity, radToDeg(sol.second) * 3600000);
00139         return sol.first;
00140     }
00141     else if (eccentricity < 1.0)
00142     {
00143         // Extremely stable Laguerre-Conway method for solving Kepler's
00144         // equation.  Only use this for high-eccentricity orbits, as it
00145         // requires more calcuation.
00146         double E = M + 0.85 * eccentricity * sign(sin(M));
00147         Solution sol = solve_iteration_fixed(SolveKeplerLaguerreConway(eccentricity, M), E, 8);
00148         return sol.first;
00149     }
00150     else if (eccentricity == 1.0)
00151     {
00152         // Nearly parabolic orbit; very common for comets
00153         // TODO: handle this
00154         return M;
00155     }
00156     else
00157     {
00158         // Laguerre-Conway method for hyperbolic (ecc > 1) orbits.
00159         double E = log(2 * M / eccentricity + 1.85);
00160         Solution sol = solve_iteration_fixed(SolveKeplerLaguerreConwayHyp(eccentricity, M), E, 30);
00161         return sol.first;
00162     }
00163 }

double EllipticalOrbit::getBoundingRadius  )  const [virtual]
 

Implements Orbit.

Definition at line 215 of file orbit.cpp.

References eccentricity, and pericenterDistance.

Referenced by MixedOrbit::MixedOrbit().

00216 {
00217     // TODO: watch out for unbounded parabolic and hyperbolic orbits
00218     return pericenterDistance * ((1.0 + eccentricity) / (1.0 - eccentricity));
00219 }

double EllipticalOrbit::getPeriod  )  const [virtual]
 

Implements Orbit.

Definition at line 209 of file orbit.cpp.

References period.

00210 {
00211     return period;
00212 }

Point3d EllipticalOrbit::positionAtE double   )  const [private]
 

Definition at line 166 of file orbit.cpp.

References argOfPeriapsis, ascendingNode, cos(), eccentricity, inclination, pericenterDistance, sin(), sqrt(), square(), Matrix3< T >::xrotation(), and Matrix3< T >::yrotation().

Referenced by positionAtTime(), and sample().

00167 {
00168     double x, z;
00169 
00170     if (eccentricity < 1.0)
00171     {
00172         double a = pericenterDistance / (1.0 - eccentricity);
00173         x = a * (cos(E) - eccentricity);
00174         z = a * sqrt(1 - square(eccentricity)) * -sin(E);
00175     }
00176     else if (eccentricity > 1.0)
00177     {
00178         double a = pericenterDistance / (1.0 - eccentricity);
00179         x = -a * (eccentricity - cosh(E));
00180         z = -a * sqrt(square(eccentricity) - 1) * -sinh(E);
00181     }
00182     else
00183     {
00184         // TODO: Handle parabolic orbits
00185         x = 0.0;
00186         z = 0.0;
00187     }
00188 
00189     Mat3d R = (Mat3d::yrotation(ascendingNode) *
00190                Mat3d::xrotation(inclination) *
00191                Mat3d::yrotation(argOfPeriapsis));
00192 
00193     return R * Point3d(x, 0, z);
00194 }

Point3d EllipticalOrbit::positionAtTime double   )  const [virtual]
 

Implements Orbit.

Definition at line 198 of file orbit.cpp.

References eccentricAnomaly(), epoch, meanAnomalyAtEpoch, period, PI, and positionAtE().

Referenced by MixedOrbit::positionAtTime().

00199 {
00200     t = t - epoch;
00201     double meanMotion = 2.0 * PI / period;
00202     double meanAnomaly = meanAnomalyAtEpoch + t * meanMotion;
00203     double E = eccentricAnomaly(meanAnomaly);
00204     
00205     return positionAtE(E);
00206 }

void EllipticalOrbit::sample double  ,
double  ,
int  ,
OrbitSampleProc
const [virtual]
 

Implements Orbit.

Definition at line 222 of file orbit.cpp.

References PI, and positionAtE().

00224 {
00225     double dE = 2 * PI / (double) nSamples;
00226     for (int i = 0; i < nSamples; i++)
00227         proc.sample(t, positionAtE(dE * i));
00228 }


Member Data Documentation

double EllipticalOrbit::argOfPeriapsis [private]
 

Definition at line 54 of file orbit.h.

Referenced by positionAtE().

double EllipticalOrbit::ascendingNode [private]
 

Definition at line 53 of file orbit.h.

Referenced by positionAtE().

double EllipticalOrbit::eccentricity [private]
 

Definition at line 51 of file orbit.h.

Referenced by eccentricAnomaly(), getBoundingRadius(), and positionAtE().

double EllipticalOrbit::epoch [private]
 

Definition at line 57 of file orbit.h.

Referenced by positionAtTime().

double EllipticalOrbit::inclination [private]
 

Definition at line 52 of file orbit.h.

Referenced by positionAtE().

double EllipticalOrbit::meanAnomalyAtEpoch [private]
 

Definition at line 55 of file orbit.h.

Referenced by positionAtTime().

double EllipticalOrbit::pericenterDistance [private]
 

Definition at line 50 of file orbit.h.

Referenced by getBoundingRadius(), and positionAtE().

double EllipticalOrbit::period [private]
 

Definition at line 56 of file orbit.h.

Referenced by getPeriod(), and positionAtTime().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:19 2006 for Celestia by  doxygen 1.4.1