Stellarium 0.15.2
Orbit.hpp
1 // orbit.h
2 //
3 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
4 //
5 // CometOrbit: Copyright (C) 2007,2008 Johannes Gajdosik
6 // Amendments (c) 2013 Georg Zotti
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
12 
13 #ifndef _ORBIT_HPP_
14 #define _ORBIT_HPP_
15 
16 #include "VecMath.hpp"
17 
18 class OrbitSampleProc;
19 
22 class Orbit
23 {
24 public:
25  Orbit(void) {}
26  virtual ~Orbit(void) {}
27 private:
28  Orbit(const Orbit&);
29  const Orbit &operator=(const Orbit&);
30 };
31 
32 
33 class EllipticalOrbit : public Orbit
34 {
35 public:
36  EllipticalOrbit(double pericenterDistance,
37  double eccentricity,
38  double inclination,
39  double ascendingNode,
40  double argOfPeriapsis,
41  double meanAnomalyAtEpoch,
42  double period,
43  double epoch, // = 2451545.0,
44  double parentRotObliquity, // = 0.0,
45  double parentRotAscendingnode, // = 0.0
46  double parentRotJ2000Longitude // = 0.0
47  );
48 
49  // Compute position for a specified Julian date and return coordinates
50  // given in "dynamical equinox and ecliptic J2000"
51  // which is the reference frame for VSOP87
52  // In order to rotate to VSOP87
53  // parentRotObliquity and parentRotAscendingnode must be supplied.
54  void positionAtTimevInVSOP87Coordinates(const double JDE, double* v) const;
55 
56  // Original one
57  Vec3d positionAtTime(const double JDE) const;
58  double getPeriod() const;
59  double getBoundingRadius() const;
60  virtual void sample(double, double, int, OrbitSampleProc&) const;
61 
62 private:
64  double eccentricAnomaly(const double M) const;
65  Vec3d positionAtE(const double E) const;
66 
67  double pericenterDistance;
68  double eccentricity;
69  double inclination;
70  double ascendingNode;
71  double argOfPeriapsis;
72  double meanAnomalyAtEpoch;
73  double period;
74  double epoch;
75  double rotateToVsop87[9];
76 };
77 
78 
79 class CometOrbit : public Orbit {
80 public:
81  CometOrbit(double pericenterDistance,
82  double eccentricity,
83  double inclination,
84  double ascendingNode,
85  double argOfPerhelion,
86  double timeAtPerihelion,
87  double orbitGoodDays,
88  double meanMotion, // GZ: for parabolics, this is W/dt in Heafner's lettering
89  double parentRotObliquity, // Comets only have parent==sun, no need for these? Oh yes, VSOP/J2000 eq frames!
90  double parentRotAscendingnode,
91  double parentRotJ2000Longitude
92  );
93  // Compute the orbit for a specified Julian day and return a "stellarium compliant" function
94  // GZ: new optional variable: updateVelocityVector, true required for dust tail orientation!
95  void positionAtTimevInVSOP87Coordinates(double JDE, double* v, bool updateVelocityVector=true);
96  // updating the tails is a bit expensive. try not to overdo it.
97  bool getUpdateTails() const { return updateTails; }
98  void setUpdateTails(const bool update){ updateTails=update; }
100  Vec3d getVelocity() const { return rdot; }
101  double getSemimajorAxis() const { return (e==1. ? 0. : q / (1.-e)); }
102  double getEccentricity() const { return e; }
103  bool objectDateValid(const double JDE) const { return (fabs(t0-JDE)<orbitGood); }
104 private:
105  const double q;
106  const double e;
107  const double i;
108  const double Om;
109  const double w;
110  const double t0;
111  const double n;
112  Vec3d rdot;
113  double rotateToVsop87[9];
114  bool updateTails;
115  const double orbitGood;
116 };
117 
118 
120 {
121  public:
122  virtual ~OrbitSampleProc() {;}
123  virtual void sample(const Vec3d&) = 0;
124 };
125 
126 /*
127  * Stuff found unused and deactivated pre-0.15
128 
129 // Custom orbit classes should be derived from CachingOrbit. The custom
130 // orbits can be expensive to compute, with more than 50 periodic terms.
131 // Celestia may need require position of a Planet more than once per frame; in
132 // order to avoid redundant calculation, the CachingOrbit class saves the
133 // result of the last calculation and uses it if the time matches the cached
134 // time.
135 class CachingOrbit : public Orbit
136 {
137 public:
138  CachingOrbit() : lastTime(1.0e-30) {} //;
139 
140  virtual Vec3d computePosition(double JDE) const = 0;
141  virtual double getPeriod() const = 0;
142  virtual double getBoundingRadius() const = 0;
143 
144  Vec3d positionAtTime(double JDE) const;
145 
146  virtual void sample(double, double, int, OrbitSampleProc& proc) const;
147 
148 private:
149  mutable Vec3d lastPosition;
150  mutable double lastTime;
151 };
152 
153 */
154 
155 #endif // _ORBIT_HPP_
Definition: Orbit.hpp:22
Vec3d getVelocity() const
return speed value [AU/d] last computed by positionAtTimevInVSOP87Coordinates(JDE, v, true)
Definition: Orbit.hpp:100