1 /*****************************************************************************\
2  * PlanetData.h
3  *
4  * Handles planetary motion calculations and conversions
5  *
6  * author: mark huss (mark@mhuss.com)
7  * Based on Bill Gray's open-source code at projectpluto.com
8  *
9 \*****************************************************************************/
10 
11 #if !defined( PLANET_DATA__H )
12 #define PLANET_DATA__H
13 
14 #include "AstroOps.h"
15 
16 class ObsInfo;
17 
18 // bodies of interest
19 //
20 enum Planet { NAP=-1, // NotAPlanet
21         SUN=0, MERCURY=1, VENUS=2, EARTH=3, MARS=4, JUPITER=5,
22         SATURN=6, URANUS=7, NEPTUNE=8, PLUTO=9, LUNA=10 };
23 
24 class PlanetData {
25 public:
PlanetData()26   PlanetData() : m_planet( NAP ) {}
PlanetData(Planet planet,double jd,ObsInfo & oi)27   PlanetData( Planet planet, double jd, ObsInfo& oi ) {
28     calc( planet, jd, oi );
29   }
30 
31   // Calculate the data for a given planet, jd, and location
32   // This function must be called (directly or via c'tor) before calling
33   // any of the other fns!
34   //
35   void calc( Planet planet, double jd, ObsInfo& oi );
36 
planet()37   Planet planet() const { return m_planet; }
jd()38   double jd() const { return ( NAP == m_planet ) ? -1. : m_jd; }
hourAngle()39   double hourAngle() const { return ( NAP == m_planet ) ? -1. : m_hourAngle; }
40 
eclipticLon()41   double eclipticLon() const { return ( NAP == m_planet ) ? -1. : m_eclipticLon; }
eclipticLat()42   double eclipticLat() const { return ( NAP == m_planet ) ? -1. : m_eclipticLat; }
radius()43   double radius()      const { return ( NAP == m_planet ) ? -1. : m_r; }
44 
45   // The &3's will limit index GPFs with low perf. penalty
eclipticLoc(int i)46   const double eclipticLoc(int i) const {
47       return ( NAP == m_planet ) ? -1. : m_eclipticLoc[i & 3];
48   }
equatorialLoc(int i)49   const double equatorialLoc(int i) const {
50       return ( NAP == m_planet ) ? -1. : m_equatorialLoc[i & 3];
51   }
altazLoc(int i)52   const double altazLoc(int i) const {
53       return ( NAP == m_planet ) ? -1. : m_altazLoc[i & 3];
54   }
55 
56 private:
57   Planet m_planet;
58 
59   double m_jd;
60   double m_r;
61   double m_eclipticLon;
62   double m_eclipticLat;
63   double m_hourAngle;
64 
65   AstroVector m_eclipticLoc;
66   AstroVector m_equatorialLoc;
67   AstroVector m_altazLoc;
68 };
69 
70 
71 
72 
73 
74 #endif  /* #if !defined( PLANET_DATA__H ) */
75