CppEphem
CEObservation.h
Go to the documentation of this file.
1 /***************************************************************************
2  * CEObservation.h: CppEphem *
3  * ----------------------------------------------------------------------- *
4  * Copyright © 2017 JCardenzana *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 
22 #ifndef CEObservation_h
23 #define CEObservation_h
24 
25 // CppEphem HEAD
26 #include "CEBody.h"
27 #include "CEDate.h"
28 #include "CEObserver.h"
29 #include "CENamespace.h"
30 #include "CESkyCoord.h"
31 
32 
34 public:
35  // Constructors
36  CEObservation() ;
37  CEObservation(CEObserver* observer, CEBody* body, CEDate* date);
38  CEObservation(const CEObservation& other);
39  virtual ~CEObservation() ;
40 
41  // Copy assignment operator
42  CEObservation& operator=(const CEObservation& other);
43 
44  // Setting underlying object pointers
45  virtual void SetObserver(CEObserver* new_observer);
46  virtual void SetBody(CEBody* new_body);
47  virtual void SetDate(CEDate* new_date);
48 
51  CEBody* Body();
52  CEDate* Date();
53  virtual double GetAzimuth_Rad();
54  virtual double GetAzimuth_Deg();
55  virtual double GetZenith_Rad();
56  virtual double GetZenith_Deg();
57  virtual double GetAltitude_Rad();
58  virtual double GetAltitude_Deg();
59  virtual double GetHourAngle_Rad();
60  virtual double GetHourAngle_Deg();
61  virtual double GetApparentXCoordinate_Rad();
62  virtual double GetApparentXCoordinate_Deg();
63  virtual double GetApparentYCoordinate_Rad();
64  virtual double GetApparentYCoordinate_Deg();
65  virtual void GetAzimuthZenith_Rad(double *azimuth, double *zenith);
66  virtual void GetAzimuthZenith_Deg(double *azimuth, double *zenith);
67  virtual void GetApparentXYCoordinate_Rad(double *apparent_X, double *apparent_Y);
68  virtual void GetApparentXYCoordinate_Deg(double *apparent_X, double *apparent_Y);
69  bool UpdateCoordinates();
70 
71 private:
72 
73  // Member functions for setup and tear down
74  void copy_members(const CEObservation& other);
75  void init_members(void);
76  void free_members(void);
77 
78  // Updates the coordinates if the date, observer or object has changed
79  bool NeedsUpdate(void);
80 
81  CEBody* body_; //<! Object being observed
82  CEDate* date_; //<! Store a pointer to a CEDate object
83  CEObserver* observer_; //<! Store a pointer to a CEObserver object
84 
85  // Cached the observed parameters to make subsequent calls faster,
86  // i.e. since they all get computed at the same time there's no need
87  // to recompute them unless something changes.
88  double cached_date_; //<! Cached date, observed params recomputed if this has changed
89  CESkyCoord cached_coords_; //<! Cached observed coordinates
90 
91  // Cache the apparent coordinates
92  double cached_hour_angle_; //<! Cached hour angle (radians)
95 };
96 
97 
98 /**********************************************************************/
102 inline
104 {
105  return observer_;
106 }
107 
108 /**********************************************************************/
112 inline
114 {
115  return body_;
116 }
117 
118 
119 /**********************************************************************/
123 inline
125 {
126  return date_;
127 }
128 
129 
130 /**********************************************************************/
134 inline
136 {
137  observer_ = new_observer;
138 }
139 
140 
141 /**********************************************************************/
145 inline
147 {
148  body_ = new_body;
149 }
150 
151 
152 /**********************************************************************/
156 inline
158 {
159  date_ = new_date;
160 }
161 
162 
163 /**********************************************************************/
166 inline
168 {
170  return cached_coords_.XCoord().Rad();
171 }
172 
173 
174 /**********************************************************************/
177 inline
179 {
180  return cached_coords_.XCoord().Deg();
181 }
182 
183 
184 /**********************************************************************/
187 inline
189 {
191  return cached_coords_.YCoord().Rad();
192 }
193 
194 
195 /**********************************************************************/
198 inline
200 {
201  return cached_coords_.YCoord().Deg();
202 }
203 
204 
205 /**********************************************************************/
208 inline
210 {
212  return (DPI/2.0) - GetZenith_Rad() ;
213 }
214 
215 
216 /**********************************************************************/
219 inline
221 {
222  return GetAltitude_Rad() * DR2D;
223 }
224 
225 
226 /**********************************************************************/
229 inline
231 {
233  return cached_hour_angle_;
234 }
235 
236 
237 /**********************************************************************/
240 inline
242 {
243  return GetHourAngle_Rad() * DR2D;
244 }
245 
246 
247 /**********************************************************************/
249 inline
251 {
253  return cached_apparentxcoord_ ;
254 }
255 
256 
257 /**********************************************************************/
260 inline
262 {
263  return GetApparentXCoordinate_Rad() * DR2D;
264 }
265 
266 
267 /**********************************************************************/
270 inline
272 {
274  return cached_apparentycoord_ ;
275 }
276 
277 
278 /**********************************************************************/
281 inline
283 {
284  return GetApparentYCoordinate_Rad() * DR2D;
285 }
286 
287 #endif /* CEObservation_h */
CEObservation::observer_
CEObserver * observer_
Definition: CEObservation.h:101
CEObservation::GetHourAngle_Rad
virtual double GetHourAngle_Rad()
Definition: CEObservation.h:230
CEObservation::date_
CEDate * date_
Definition: CEObservation.h:100
CEObservation::operator=
CEObservation & operator=(const CEObservation &other)
Copy assignment operator.
Definition: CEObservation.cpp:86
CEObservation::GetZenith_Deg
virtual double GetZenith_Deg()
Definition: CEObservation.h:199
CEObservation::SetObserver
virtual void SetObserver(CEObserver *new_observer)
Set underlying CEObserver object.
Definition: CEObservation.h:135
CEObservation::GetApparentXCoordinate_Rad
virtual double GetApparentXCoordinate_Rad()
Definition: CEObservation.h:250
CEObservation::free_members
void free_members(void)
Deallocate memory.
Definition: CEObservation.cpp:219
CENamespace.h
CEDate
Definition: CEDate.h:43
CEObservation::GetAzimuthZenith_Deg
virtual void GetAzimuthZenith_Deg(double *azimuth, double *zenith)
Returns both the azimuth and zenith angle of a given 'body_' as observed by 'observer_' on the date g...
Definition: CEObservation.cpp:119
CEObservation::GetAltitude_Rad
virtual double GetAltitude_Rad()
Definition: CEObservation.h:209
CEObservation::cached_apparentycoord_
double cached_apparentycoord_
Definition: CEObservation.h:112
CEObservation::GetApparentYCoordinate_Deg
virtual double GetApparentYCoordinate_Deg()
Definition: CEObservation.h:282
CESkyCoord
Definition: CESkyCoord.h:49
CEObservation::Observer
CEObserver * Observer()
Access the underlying objects.
Definition: CEObservation.h:103
CEObservation::init_members
void init_members(void)
Initialize the data members.
Definition: CEObservation.cpp:198
CEObserver.h
CEObservation::~CEObservation
virtual ~CEObservation()
Destructor.
Definition: CEObservation.cpp:74
CEObservation::GetApparentXYCoordinate_Deg
virtual void GetApparentXYCoordinate_Deg(double *apparent_X, double *apparent_Y)
Returns both the observed x,y coordinates of a given 'body_' as observed by 'observer_' on the date g...
Definition: CEObservation.cpp:150
CEObservation::GetHourAngle_Deg
virtual double GetHourAngle_Deg()
Definition: CEObservation.h:241
CEDate.h
CEObservation::UpdateCoordinates
bool UpdateCoordinates()
Update the stored coordinates.
Definition: CEObservation.cpp:163
CEObservation::cached_date_
double cached_date_
Definition: CEObservation.h:106
CEObservation::CEObservation
CEObservation()
Default constructor.
Definition: CEObservation.cpp:36
CEObservation::GetApparentXCoordinate_Deg
virtual double GetApparentXCoordinate_Deg()
Definition: CEObservation.h:261
CEAngle::Rad
static CEAngle Rad(const double &angle)
Return angle constructed from a radians angle.
Definition: CEAngle.cpp:340
CEObservation::NeedsUpdate
bool NeedsUpdate(void)
Check whether the date has changed since the last time all of the parameters were updated (i....
Definition: CEObservation.cpp:230
CEObservation::copy_members
void copy_members(const CEObservation &other)
Copy data members from another object.
Definition: CEObservation.cpp:179
CEObservation::cached_apparentxcoord_
double cached_apparentxcoord_
Definition: CEObservation.h:111
CEObservation::Body
CEBody * Body()
Access underlying CEBody object.
Definition: CEObservation.h:113
CEObservation::GetAzimuth_Rad
virtual double GetAzimuth_Rad()
Definition: CEObservation.h:167
CEObservation::cached_coords_
CESkyCoord cached_coords_
Definition: CEObservation.h:107
CEObservation::GetAzimuthZenith_Rad
virtual void GetAzimuthZenith_Rad(double *azimuth, double *zenith)
Returns both the azimuth and zenith angle of a given 'body_' as observed by 'observer_' on the date g...
Definition: CEObservation.cpp:105
CEObserver
Definition: CEObserver.h:28
CEObservation::GetApparentYCoordinate_Rad
virtual double GetApparentYCoordinate_Rad()
Definition: CEObservation.h:271
CEBody.h
CEObservation
Definition: CEObservation.h:33
CEObservation::cached_hour_angle_
double cached_hour_angle_
Definition: CEObservation.h:110
CEObservation::GetAzimuth_Deg
virtual double GetAzimuth_Deg()
Definition: CEObservation.h:178
CEBody
Definition: CEBody.h:39
CEObservation::SetBody
virtual void SetBody(CEBody *new_body)
Set underlying CEBody object.
Definition: CEObservation.h:146
CEObservation::GetZenith_Rad
virtual double GetZenith_Rad()
Definition: CEObservation.h:188
CESkyCoord.h
CEObservation::Date
CEDate * Date()
Access underlying CEDate object.
Definition: CEObservation.h:124
CEObservation::GetAltitude_Deg
virtual double GetAltitude_Deg()
Definition: CEObservation.h:220
CEObservation::body_
CEBody * body_
Definition: CEObservation.h:99
CEObservation::SetDate
virtual void SetDate(CEDate *new_date)
Set underlying CEDate object.
Definition: CEObservation.h:157
CEAngle::Deg
static CEAngle Deg(const double &angle)
Return angle (radians) constructed from a degree angle.
Definition: CEAngle.cpp:317
CEObservation::GetApparentXYCoordinate_Rad
virtual void GetApparentXYCoordinate_Rad(double *apparent_X, double *apparent_Y)
Returns both the observed x,y coordinates of a given 'body_' as observed by 'observer_' on the date g...
Definition: CEObservation.cpp:135
CESkyCoord::XCoord
virtual CEAngle XCoord(const CEDate &jd=CppEphem::julian_date_J2000()) const
Return x coordinate at given Julian date.
Definition: CESkyCoord.h:227
CESkyCoord::YCoord
virtual CEAngle YCoord(const CEDate &jd=CppEphem::julian_date_J2000()) const
Return y coordinate at given Julian date.
Definition: CESkyCoord.h:240