orsa_orbit.h

Go to the documentation of this file.
00001 /* 
00002    ORSA - Orbit Reconstruction, Simulation and Analysis
00003    Copyright (C) 2002-2004 Pasquale Tricarico
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    As a special exception, Pasquale Tricarico gives permission to
00011    link this program with Qt commercial edition, and distribute the
00012    resulting executable, without including the source code for the Qt
00013    commercial edition in the source distribution.
00014    
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019    
00020    You should have received a copy of the GNU General Public License
00021    along with this program; if not, write to the Free Software
00022    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 
00025 #ifndef _ORSA_ORBIT_H_
00026 #define _ORSA_ORBIT_H_
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include "config.h"
00030 #endif
00031 
00032 #include "orsa_coord.h"
00033 #include "orsa_secure_math.h"
00034 #include "orsa_frame.h"
00035 
00036 #include <string>
00037 #include <vector>
00038 #include <list>
00039 
00040 namespace orsa {
00041   
00042   class Observation {
00043   public:
00044     // used to sort observations
00045     inline bool operator < (const Observation &obs) const {
00046       return (date.GetJulian() < obs.date.GetJulian());
00047     }
00048     
00049   public:
00050     std::string designation;
00051     std::string discovery_asterisk;
00052     Date   date;
00053     Angle  ra, dec;         
00054     double mag; // magnitude
00055     std::string obscode;
00056   };
00057   
00058   class Sky {
00059   public:
00060     void Set(Angle & ra, Angle & dec) {
00061       _ra    = ra;
00062       _dec   = dec;
00063     }
00064     
00065   public:
00066     inline Angle ra()  const { return _ra; }
00067     inline Angle dec() const { return _dec; }
00068     
00069   public:
00070     void Compute_J2000(const Vector & relative_position);
00071     
00072   public:
00073     double delta_arcsec(const Observation & obs) const;
00074     
00075   private:
00076     Angle _ra, _dec;
00077   };
00078   
00079   class Orbit {
00080   public:
00081     Orbit() { };
00082     
00083   public:
00084     inline double Period() const { return (secure_sqrt(4*pisq*a*a*a/mu)); }
00085     
00086     // eccentric anomaly
00087     double GetE() const;
00088     
00089   public:
00090     void RelativePosVel(Vector & relative_position, Vector & relative_velocity) const;
00091     
00092   public:
00093     void Compute(const Vector & dr, const Vector & dv, const double mu);
00094     void Compute(const Body & b, const Body & ref_b);
00095     
00096   public:
00097     double a,e,i,omega_node,omega_pericenter,M;
00098     double mu; // G*(m+M)
00099   };
00100   
00101   class OrbitWithEpoch : public Orbit {
00102   public:
00103     inline OrbitWithEpoch() : Orbit() { }
00104     inline OrbitWithEpoch(const Orbit & orbit) : Orbit(orbit) { }
00105     inline OrbitWithEpoch(const OrbitWithEpoch & orbit) : Orbit(orbit), epoch(orbit.epoch) { }
00106     
00107   public:
00108     /* 
00109        inline void Compute(const Vector & dr, const Vector & dv, const double mu) {
00110        Orbit::Compute(dr,dv,mu);
00111        }
00112     */
00113     
00114     inline void Compute(const Vector & dr, const Vector & dv, const double mu, const UniverseTypeAwareTime &epoch_in) {
00115       epoch = epoch_in;
00116       Orbit::Compute(dr,dv,mu);
00117     }
00118     
00119     /* 
00120        inline void Compute(const Body & b, const Body & ref_b) {
00121        Orbit::Compute(b, ref_b);
00122        }
00123     */
00124     
00125     inline void Compute(const Body & b, const Body & ref_b, const UniverseTypeAwareTime & epoch_in) {
00126       epoch = epoch_in;
00127       Orbit::Compute(b, ref_b);
00128     }
00129     
00130   public:    
00131     inline void RelativePosVel(Vector & relative_position, Vector & relative_velocity) const {
00132       Orbit::RelativePosVel(relative_position,relative_velocity);
00133     }
00134     
00135   public:
00136     inline void RelativePosVel(Vector & relative_position, Vector & relative_velocity, const UniverseTypeAwareTime &epoch_in) const {
00137       OrbitWithEpoch o(*this);
00138       o.M += twopi*(epoch_in.Time() - epoch.Time())/Period();
00139       o.M  = std::fmod(10*twopi+std::fmod(o.M,twopi),twopi);
00140       o.RelativePosVel(relative_position,relative_velocity);
00141     }
00142     
00143   public:
00144     UniverseTypeAwareTime epoch;
00145     double libration_angle; // to be removed soon!!
00146   };
00147   
00148   //! The RMS of the residuals in arcsec units
00149   double residual(const Observation&, const OrbitWithEpoch&);
00150   double RMS_residuals(const std::vector<Observation>&, const OrbitWithEpoch&);
00151   
00152   /* 
00153      Vector Position(const Orbit&);
00154      Vector Position(const Orbit&, const double);
00155      
00156      Vector Velocity(const Orbit&);
00157      Vector Velocity(const Orbit&, const double);
00158      
00159      void RelativePosVel(const Orbit&, Vector&, Vector&);
00160      void RelativePosVel(const Orbit&, Vector&, Vector&, const double);
00161      void RelativePosVel(const Orbit&, Vector&, Vector&, const Date);
00162   */
00163   
00164   // sky position of an object
00165   // Sky PropagatedSky(const OrbitWithEpoch&, const UniverseTypeAwareTime&, const std::string &obscode, bool integrate=true);
00166   // Sky PropagatedSky_J2000(const OrbitWithEpoch&, const UniverseTypeAwareTime&, const std::string &obscode, bool integrate=true);
00167   Sky PropagatedSky_J2000(const OrbitWithEpoch&, const UniverseTypeAwareTime&, const std::string &obscode, const bool integrate=true, const bool light_time_corrections=true);
00168   
00169   // an optimized class for frequent position computations of an object with a given orbit
00170   class OptimizedOrbitPositions {
00171   public:
00172     OptimizedOrbitPositions(const OrbitWithEpoch &orbit);
00173     
00174   public:
00175     // Sky PropagatedSky(const UniverseTypeAwareTime&, const std::string &obscode, const bool integrate=true, const bool light_time_corrections=true);
00176     Sky PropagatedSky_J2000(const UniverseTypeAwareTime&, const std::string &obscode, const bool integrate=true, const bool light_time_corrections=true);
00177     void PropagatedPosVel(const UniverseTypeAwareTime&, Vector&, Vector&, bool integrate=true);
00178     OrbitWithEpoch PropagatedOrbit(const UniverseTypeAwareTime&, bool integrate=true);
00179     
00180   private:
00181     const OrbitWithEpoch _orbit;
00182     std::list<JPL_planets> l;
00183     std::vector<Frame> frames;
00184   };
00185   
00186 #ifndef HAVE_GSL // else: definitions in orsa_orbit_gsl.h
00187   class Asteroid {
00188   public:
00189     int n;    
00190     OrbitWithEpoch orb;
00191     std::string name;
00192     double mag;
00193   };
00194   
00195   class AsteroidDatabase : public std::vector<Asteroid> {
00196     
00197   };
00198   
00199   class ObservationCandidate { 
00200   public:
00201     Asteroid        a;
00202     Observation     o;
00203     Angle           delta;
00204   };
00205 #endif // HAVE_GSL
00206   
00207   class Location {
00208   public:
00209     double lon,pxy,pz;
00210     std::string name;
00211     // bool present;  
00212   };
00213   
00214 } // namespace orsa
00215 
00216 #endif // _ORSA_ORBIT_H_

Generated on Thu Jul 13 06:45:22 2006 for liborsa by  doxygen 1.4.7