CppEphem
CESkyCoord.h
Go to the documentation of this file.
1 /***************************************************************************
2  * CESkyCoord.h: CppEphem *
3  * ----------------------------------------------------------------------- *
4  * Copyright © 2019 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 CESkyCoord_h
23 #define CESkyCoord_h
24 
25 #include <string>
26 #include <vector>
27 
28 // CppEphem HEADERS
29 #include "CEAngle.h"
30 #include "CEDate.h"
31 #include "CENamespace.h"
32 #include "CEException.h"
33 #include "CEObserver.h"
34 #include "CECoordinates.h"
35 
36 // SOFA HEADER
37 #include "sofa.h"
38 
40 enum class CESkyCoordType
41 {
42  CIRS=0,
43  ICRS=1,
44  GALACTIC=2,
45  OBSERVED=3,
46  ECLIPTIC=4
47 };
48 
49 // Class for handling sky coordinates
50 class CESkyCoord {
51 
52  friend bool operator==(const CESkyCoord& lhs, const CESkyCoord& rhs);
53  friend bool operator!=(const CESkyCoord& lhs, const CESkyCoord& rhs);
54 
55 public:
56 
57  /****** CONSTRUCTORS ******/
58  CESkyCoord() ;
59  CESkyCoord(const CEAngle& xcoord,
60  const CEAngle& ycoord,
61  const CESkyCoordType& coord_type=CESkyCoordType::ICRS) ;
62  explicit CESkyCoord(const CECoordinates& other);
63  CESkyCoord(const CESkyCoord& other) ;
64  virtual ~CESkyCoord() ;
65 
66  CESkyCoord& operator=(const CESkyCoord& other);
67 
68  /*********************************************************
69  * Angular separation between two coordinate positions
70  *********************************************************/
71  virtual CEAngle AngularSeparation(const CESkyCoord& coords) const;
72  static CEAngle AngularSeparation(const CESkyCoord& coords1,
73  const CESkyCoord& coords2);
74  static CEAngle AngularSeparation(const CEAngle& xcoord_first,
75  const CEAngle& ycoord_first,
76  const CEAngle& xcoord_second,
77  const CEAngle& ycoord_second);
78 
79  /**********************************************************
80  * Methods for accessing the coordinate information
81  **********************************************************/
82 
83  virtual CEAngle XCoord(const CEDate& jd=CppEphem::julian_date_J2000()) const;
84  virtual CEAngle YCoord(const CEDate& jd=CppEphem::julian_date_J2000()) const;
85 
86  // Return coordinate system
87  CESkyCoordType GetCoordSystem(void) const;
88 
89  /**********************************************************
90  * Methods for converting between coordinate types
91  **********************************************************/
92  // Note that whenever a date is required, the default will be set to the
93  // start of the J2000 epoch (January 1, 2000 at 12:00 GMT). This corresponds
94  // to the Julian Date of 2451545.0.
95 
96  // Convert from CIRS to other coordinates
97  static void CIRS2ICRS(const CESkyCoord& in_cirs,
98  CESkyCoord* out_icrs,
99  const CEDate& date=CEDate());
100  static void CIRS2Galactic(const CESkyCoord& in_cirs,
101  CESkyCoord* out_galactic,
102  const CEDate& date=CEDate());
103  static void CIRS2Observed(const CESkyCoord& in_cirs,
104  CESkyCoord* out_observed,
105  const CEDate& date,
106  const CEObserver& observer,
107  CESkyCoord* observed_cirs=nullptr,
108  CEAngle* hour_angle=nullptr);
109  static void CIRS2Ecliptic(const CESkyCoord& in_cirs,
110  CESkyCoord* out_ecliptic,
111  const CEDate& date=CEDate());
112 
113  // Convert from ICRS to other coordinates
114  static void ICRS2CIRS(const CESkyCoord& in_icrs,
115  CESkyCoord* out_cirs,
116  const CEDate& date=CEDate());
117  static void ICRS2Galactic(const CESkyCoord& in_icrs,
118  CESkyCoord* out_galactic);
119  static void ICRS2Observed(const CESkyCoord& in_icrs,
120  CESkyCoord* out_observed,
121  const CEDate& date,
122  const CEObserver& observer,
123  CESkyCoord* observed_cirs=nullptr,
124  CEAngle* hour_angle=nullptr);
125  static void ICRS2Ecliptic(const CESkyCoord& in_icrs,
126  CESkyCoord* out_ecliptic,
127  const CEDate& date=CEDate());
128 
129  // Convert from GALACTIC to other coordinates
130  static void Galactic2CIRS(const CESkyCoord& in_galactic,
131  CESkyCoord* out_cirs,
132  const CEDate& date=CEDate());
133  static void Galactic2ICRS(const CESkyCoord& in_galactic,
134  CESkyCoord* out_icrs);
135  static void Galactic2Observed(const CESkyCoord& in_galactic,
136  CESkyCoord* out_observed,
137  const CEDate& date,
138  const CEObserver& observer,
139  CESkyCoord* observed_galactic=nullptr,
140  CEAngle* hour_angle=nullptr);
141  static void Galactic2Ecliptic(const CESkyCoord& in_galactic,
142  CESkyCoord* out_ecliptic,
143  const CEDate& date=CEDate());
144 
145  // Convert from OBSERVED to other coordinates
146  static void Observed2CIRS(const CESkyCoord& in_observed,
147  CESkyCoord* out_cirs,
148  const CEDate& date,
149  const CEObserver& observer);
150  static void Observed2ICRS(const CESkyCoord& in_observed,
151  CESkyCoord* out_icrs,
152  const CEDate& date,
153  const CEObserver& observer);
154  static void Observed2Galactic(const CESkyCoord& in_observed,
155  CESkyCoord* out_galactic,
156  const CEDate& date,
157  const CEObserver& observer);
158  static void Observed2Ecliptic(const CESkyCoord& in_observed,
159  CESkyCoord* out_ecliptic,
160  const CEDate& date,
161  const CEObserver& observer);
162 
163  // Convert from ECLIPTIC to other coordinates
164  static void Ecliptic2CIRS(const CESkyCoord& in_ecliptic,
165  CESkyCoord* out_cirs,
166  const CEDate& date=CEDate());
167  static void Ecliptic2ICRS(const CESkyCoord& in_ecliptic,
168  CESkyCoord* out_icrs,
169  const CEDate& date=CEDate());
170  static void Ecliptic2Galactic(const CESkyCoord& in_ecliptic,
171  CESkyCoord* out_galactic,
172  const CEDate& date=CEDate());
173  static void Ecliptic2Observed(const CESkyCoord& in_ecliptic,
174  CESkyCoord* out_observed,
175  const CEDate& date,
176  const CEObserver& observer);
177 
178  /*********************************************************
179  * More generic methods for converting between coordinate types
180  *********************************************************/
181  CESkyCoord ConvertTo(const CESkyCoordType& output_coord_type,
182  const CEDate& date=CEDate(),
183  const CEObserver& observer=CEObserver());
184  CESkyCoord ConvertToCIRS(const CEDate& date=CEDate(),
185  const CEObserver& observer=CEObserver());
186  CESkyCoord ConvertToICRS(const CEDate& date=CEDate(),
187  const CEObserver& observer=CEObserver());
189  const CEObserver& observer=CEObserver());
191  const CEObserver& observer=CEObserver());
193  const CEObserver& observer=CEObserver());
194 
195  /*********************************************************
196  * Methods for setting the coordinates of this object
197  *********************************************************/
198  virtual void SetCoordinates(const CEAngle& xcoord,
199  const CEAngle& ycoord,
200  const CESkyCoordType& coord_type=CESkyCoordType::ICRS) const;
201  virtual void SetCoordinates(const CESkyCoord& coords);
202 
203  // Support methods
204  std::string print(void) const;
205 
206 private:
207  /*********************************************************
208  * Private methods
209  *********************************************************/
210  void copy_members(const CESkyCoord& other);
211  void free_members(void);
212  void init_members(void);
213 
214  // Coordinate variables
215  mutable CEAngle xcoord_; //<! X coordinate
216  mutable CEAngle ycoord_; //<! Y coordinate
217  mutable CESkyCoordType coord_type_; //<! Coordinate system to which 'xcoord_' and 'ycoord_' belong.
218 };
219 
220 
221 /**********************************************************************/
227 inline
228 CEAngle CESkyCoord::XCoord(const CEDate& jd) const
229 {
230  return xcoord_;
231 }
232 
233 
234 /**********************************************************************/
240 inline
241 CEAngle CESkyCoord::YCoord(const CEDate& jd) const
242 {
243  return ycoord_;
244 }
245 
246 
247 /**********************************************************************/
251 inline
253 {
254  return coord_type_;
255 }
256 
257 #endif /* CESkyCoord_h */
CESkyCoord::ConvertToEcliptic
CESkyCoord ConvertToEcliptic(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to ECLIPTIC coordinates.
Definition: CESkyCoord.cpp:965
CESkyCoordType::ICRS
RA, Dec (referenced at the barycenter of the solarsystem)
CESkyCoord::Galactic2ICRS
static void Galactic2ICRS(const CESkyCoord &in_galactic, CESkyCoord *out_icrs)
GALACTIC -> ICRS coordinate conversion.
Definition: CESkyCoord.cpp:492
CENamespace.h
CESkyCoord::ConvertToCIRS
CESkyCoord ConvertToCIRS(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to CIRS coordinates.
Definition: CESkyCoord.cpp:817
CESkyCoord::Galactic2Ecliptic
static void Galactic2Ecliptic(const CESkyCoord &in_galactic, CESkyCoord *out_ecliptic, const CEDate &date=CEDate())
GALACTIC -> ECLIPTIC coordinate conversion.
Definition: CESkyCoord.cpp:552
CESkyCoordType
CESkyCoordType
The following enum specifies what coordinates this object represents.
Definition: CESkyCoord.h:39
CESkyCoord::Ecliptic2ICRS
static void Ecliptic2ICRS(const CESkyCoord &in_ecliptic, CESkyCoord *out_icrs, const CEDate &date=CEDate())
ECLIPTIC -> ICRS coordinate conversion.
Definition: CESkyCoord.cpp:706
CECoordinateType::GALACTIC
Galacitc longitude, latitude.
CEDate
Definition: CEDate.h:43
CESkyCoord::xcoord_
CEAngle xcoord_
Definition: CESkyCoord.h:208
CESkyCoord::Galactic2Observed
static void Galactic2Observed(const CESkyCoord &in_galactic, CESkyCoord *out_observed, const CEDate &date, const CEObserver &observer, CESkyCoord *observed_galactic=nullptr, CEAngle *hour_angle=nullptr)
GALACTIC -> OBSERVED coordinate conversion.
Definition: CESkyCoord.cpp:520
CESkyCoord
Definition: CESkyCoord.h:49
CESkyCoord::CIRS2ICRS
static void CIRS2ICRS(const CESkyCoord &in_cirs, CESkyCoord *out_icrs, const CEDate &date=CEDate())
Convert CIRS to ICRS coordinates.
Definition: CESkyCoord.cpp:201
CEObserver.h
CESkyCoord::AngularSeparation
virtual CEAngle AngularSeparation(const CESkyCoord &coords) const
Get the angular separation between the coordinates represented by this object and another coordinate ...
Definition: CESkyCoord.cpp:119
CESkyCoord::ICRS2Galactic
static void ICRS2Galactic(const CESkyCoord &in_icrs, CESkyCoord *out_galactic)
ICRS -> GALACTIC coordinate conversion.
Definition: CESkyCoord.cpp:379
CESkyCoord::CIRS2Galactic
static void CIRS2Galactic(const CESkyCoord &in_cirs, CESkyCoord *out_galactic, const CEDate &date=CEDate())
Convert CIRS to Galactic coordinates.
Definition: CESkyCoord.cpp:235
CESkyCoord::CIRS2Observed
static void CIRS2Observed(const CESkyCoord &in_cirs, CESkyCoord *out_observed, const CEDate &date, const CEObserver &observer, CESkyCoord *observed_cirs=nullptr, CEAngle *hour_angle=nullptr)
CIRS -> Observed (or observer specific) coordinate conversion.
Definition: CESkyCoord.cpp:258
CECoordinateType::ICRS
RA, Dec (referenced at the barycenter of the solarsystem)
CEDate.h
CESkyCoord::ICRS2Ecliptic
static void ICRS2Ecliptic(const CESkyCoord &in_icrs, CESkyCoord *out_ecliptic, const CEDate &date=CEDate())
ICRS -> ECLIPTIC coordinate conversion.
Definition: CESkyCoord.cpp:440
CEException.h
CESkyCoord::operator=
CESkyCoord & operator=(const CESkyCoord &other)
Overloaded '=' (assignment) operator.
Definition: CESkyCoord.cpp:99
CESkyCoord::ICRS2CIRS
static void ICRS2CIRS(const CESkyCoord &in_icrs, CESkyCoord *out_cirs, const CEDate &date=CEDate())
ICRS -> CIRS coordinate conversion.
Definition: CESkyCoord.cpp:342
CECoordinates.h
CEAngle
Definition: CEAngle.h:38
CESkyCoord::Ecliptic2CIRS
static void Ecliptic2CIRS(const CESkyCoord &in_ecliptic, CESkyCoord *out_cirs, const CEDate &date=CEDate())
ECLIPTIC -> CIRS coordinate conversion.
Definition: CESkyCoord.cpp:686
CppEphem::julian_date_J2000
double julian_date_J2000()
Julian Date corresponding to J2000.
Definition: CENamespace.h:67
CEAngle.h
CESkyCoord::GetCoordSystem
CESkyCoordType GetCoordSystem(void) const
Return coordinate system.
Definition: CESkyCoord.h:251
CESkyCoord::free_members
void free_members(void)
Cleanup data members that need to be freed or cleared.
Definition: CESkyCoord.cpp:1052
CESkyCoord::init_members
void init_members(void)
Set initial values and allocate memory for data members.
Definition: CESkyCoord.cpp:1061
CESkyCoord::Ecliptic2Galactic
static void Ecliptic2Galactic(const CESkyCoord &in_ecliptic, CESkyCoord *out_galactic, const CEDate &date=CEDate())
ECLIPTIC -> GALACTIC coordinate conversion.
Definition: CESkyCoord.cpp:737
CESkyCoord::ConvertToObserved
CESkyCoord ConvertToObserved(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to OBSERVED coordinates.
Definition: CESkyCoord.cpp:928
CESkyCoord::ICRS2Observed
static void ICRS2Observed(const CESkyCoord &in_icrs, CESkyCoord *out_observed, const CEDate &date, const CEObserver &observer, CESkyCoord *observed_cirs=nullptr, CEAngle *hour_angle=nullptr)
ICRS -> OBSERVED coordinate conversion.
Definition: CESkyCoord.cpp:407
CESkyCoord::Observed2CIRS
static void Observed2CIRS(const CESkyCoord &in_observed, CESkyCoord *out_cirs, const CEDate &date, const CEObserver &observer)
OBSERVED -> CIRS coordinate conversion.
Definition: CESkyCoord.cpp:573
CESkyCoord::CIRS2Ecliptic
static void CIRS2Ecliptic(const CESkyCoord &in_cirs, CESkyCoord *out_ecliptic, const CEDate &date=CEDate())
Convert CIRS to ECLIPTIC coordinates.
Definition: CESkyCoord.cpp:322
CESkyCoord::print
std::string print(void) const
Generate a message string that specifies the information about this coordinate.
Definition: CESkyCoord.cpp:1026
CECoordinates
Definition: CECoordinates.h:48
CESkyCoord::ConvertToGalactic
CESkyCoord ConvertToGalactic(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to GALACTIC coordinates.
Definition: CESkyCoord.cpp:891
CESkyCoord::~CESkyCoord
virtual ~CESkyCoord()
Destructor.
Definition: CESkyCoord.cpp:90
CESkyCoord::CESkyCoord
CESkyCoord()
Default constructor.
Definition: CESkyCoord.cpp:38
CESkyCoord::operator==
friend bool operator==(const CESkyCoord &lhs, const CESkyCoord &rhs)
Compare two coordinate objects.
Definition: CESkyCoord.cpp:1074
CEObserver
Definition: CEObserver.h:28
CECoordinateType::CIRS
RA, Dec (referenced at the center of the Earth)
CESkyCoord::ycoord_
CEAngle ycoord_
Definition: CESkyCoord.h:209
CESkyCoord::copy_members
void copy_members(const CESkyCoord &other)
Copy data members from another CESkyCoord object.
Definition: CESkyCoord.cpp:1041
CESkyCoord::Observed2Galactic
static void Observed2Galactic(const CESkyCoord &in_observed, CESkyCoord *out_galactic, const CEDate &date, const CEObserver &observer)
OBSERVED -> GALACTIC coordinate conversion.
Definition: CESkyCoord.cpp:643
CESkyCoord::operator!=
friend bool operator!=(const CESkyCoord &lhs, const CESkyCoord &rhs)
Compare two coordinate objects.
Definition: CESkyCoord.cpp:1102
CESkyCoord::Ecliptic2Observed
static void Ecliptic2Observed(const CESkyCoord &in_ecliptic, CESkyCoord *out_observed, const CEDate &date, const CEObserver &observer)
ECLIPTIC -> OBSERVED coordinate conversion.
Definition: CESkyCoord.cpp:758
CESkyCoord::SetCoordinates
virtual void SetCoordinates(const CEAngle &xcoord, const CEAngle &ycoord, const CESkyCoordType &coord_type=CESkyCoordType::ICRS) const
Set the coordinates of this object.
Definition: CESkyCoord.cpp:1000
CESkyCoord::Observed2ICRS
static void Observed2ICRS(const CESkyCoord &in_observed, CESkyCoord *out_icrs, const CEDate &date, const CEObserver &observer)
OBSERVED -> ICRS coordinate conversion.
Definition: CESkyCoord.cpp:621
CESkyCoord::Observed2Ecliptic
static void Observed2Ecliptic(const CESkyCoord &in_observed, CESkyCoord *out_ecliptic, const CEDate &date, const CEObserver &observer)
OBSERVED -> ECLIPTIC coordinate conversion.
Definition: CESkyCoord.cpp:665
CECoordinateType::OBSERVED
Azimuth, Zenith (requires additional observer information)
CESkyCoordType::ECLIPTIC
Ecliptic longitude, latitude.
CESkyCoord::Galactic2CIRS
static void Galactic2CIRS(const CESkyCoord &in_galactic, CESkyCoord *out_cirs, const CEDate &date=CEDate())
GALACTIC -> CIRS coordinate conversion.
Definition: CESkyCoord.cpp:471
CESkyCoord::ConvertToICRS
CESkyCoord ConvertToICRS(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to ICRS coordinates.
Definition: CESkyCoord.cpp:854
CESkyCoord::coord_type_
CESkyCoordType coord_type_
Definition: CESkyCoord.h:210
CESkyCoord::ConvertTo
CESkyCoord ConvertTo(const CESkyCoordType &output_coord_type, const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert these coordinates to another coordinate system NOTE: If this object is not OBSERVED coordinat...
Definition: CESkyCoord.cpp:786
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