GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSkyRegionCircle.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GSkyRegionCircle.hpp - circular sky region class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2013-2020 by Michael Mayer *
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  * @file GSkyRegionCircle.hpp
23  * @brief Circular sky region class interface definition
24  * @author Michael Mayer
25  */
26 
27 #ifndef GSKYREGIONCIRCLE_HPP
28 #define GSKYREGIONCIRCLE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <vector>
32 #include <string>
33 #include "GMath.hpp"
34 #include "GSkyDir.hpp"
35 #include "GSkyRegion.hpp"
36 
37 
38 /***********************************************************************//**
39  * @class GSkyRegionCircle
40  *
41  * @brief Interface for the circular sky region class
42  *
43  * This class provides an implementation for a circular sky region. The sky
44  * region is defined by an array of parameters, the meaning of which is
45  * specific to the derived class where the region type or shape is defined.
46  * The parameters are GModelPar objects for convenience.
47  *
48  * The class holds several properties such as solid angle subtended by the
49  * region and computed through internal method compute_solid().
50  *
51  * To be clarified:
52  * - Do we want a member relating the region to an observation run ?
53  * - Constructor and read/write using XML may not be needed if we use DS9
54  * region file format ?
55  * - Replace GModelPar by double for the parameters (GModelPar is overkill) ?
56  *
57  ***************************************************************************/
58 class GSkyRegionCircle : public GSkyRegion {
59 
60  // Operator friends
61  friend bool operator==(const GSkyRegionCircle &a, const GSkyRegionCircle &b);
62  friend bool operator!=(const GSkyRegionCircle &a, const GSkyRegionCircle &b);
63 
64 public:
65  // Constructors and destructors
66  GSkyRegionCircle(void);
67  GSkyRegionCircle(const GSkyDir& centre, const double& radius);
68  GSkyRegionCircle(const double& ra, const double& dec, const double& radius);
69  explicit GSkyRegionCircle(const std::string& line);
70  GSkyRegionCircle(const GSkyRegionCircle& region);
71  virtual ~GSkyRegionCircle(void);
72 
73  // Operators
75 
76  // Implemented methods
77  void clear(void);
78  GSkyRegionCircle* clone(void) const;
79  std::string classname(void) const;
80  const double& radius(void) const;
81  void radius(const double& radius);
82  const GSkyDir& centre(void) const;
83  void centre(const GSkyDir& centre);
84  void centre(const double& ra,const double& dec);
85  double ra(void) const;
86  double dec(void) const;
87  void read(const std::string& line);
88  std::string write(void) const;
89  bool contains(const GSkyDir& dir) const;
90  bool contains(const GSkyRegion& reg) const;
91  bool overlaps(const GSkyRegion& reg) const;
92  std::string print(const GChatter& chatter = NORMAL) const;
93 
94 protected:
95  // Protected methods
96  void init_members(void);
97  void copy_members(const GSkyRegionCircle& region);
98  void free_members(void);
99  void compute_solid_angle(void);
100 
101  // Protected members
102  GSkyDir m_centre; //!< Centre or reference point of the region
103  double m_radius; //!< Radius of circular the region (degrees)
104 };
105 
106 
107 /***********************************************************************//**
108  * @brief Return class name
109  *
110  * @return String containing the class name ("GSkyRegionCircle").
111  ***************************************************************************/
112 inline
113 std::string GSkyRegionCircle::classname(void) const
114 {
115  return ("GSkyRegionCircle");
116 }
117 
118 
119 /***********************************************************************//**
120  * @brief Return circular region radius (in degrees)
121  *
122  * @return Region radius [deg].
123  *
124  * Returns the region radius in degrees.
125  ***************************************************************************/
126 inline
127 const double& GSkyRegionCircle::radius(void) const
128 {
129  return (m_radius);
130 }
131 
132 
133 /***********************************************************************//**
134  * @brief Return circular region centre
135  *
136  * @return Region centre.
137  *
138  * Returns the region centre.
139  ***************************************************************************/
140 inline
142 {
143  return (m_centre);
144 }
145 
146 
147 /***********************************************************************//**
148  * @brief Set circular region centre
149  *
150  * @param[in] dir Region centre.
151  *
152  * Sets the centre of the circular region to the specified sky direction.
153  ***************************************************************************/
154 inline
156 {
157  // Set centre
158  m_centre = dir;
159 
160  // Return
161  return;
162 }
163 
164 
165 /***********************************************************************//**
166  * @brief Set circular region centre Right Ascension and Declincation
167  *
168  * @param[in] ra Right Ascension [deg].
169  * @param[in] dec Declination [deg].
170  *
171  * Sets the centre of the circular region to the specified Right Ascension
172  * and Declination.
173  ***************************************************************************/
174 inline
175 void GSkyRegionCircle::centre(const double& ra, const double& dec)
176 {
177  // Set centre values
178  m_centre.radec_deg(ra,dec);
179 
180  // Return
181  return;
182 }
183 
184 
185 /***********************************************************************//**
186  * @brief Return circular region centre Right Ascension
187  *
188  * @return Region centre Right Ascension [deg].
189  *
190  * Returns the region centre Right Ascension in degrees.
191  ***************************************************************************/
192 inline
193 double GSkyRegionCircle::ra(void) const
194 {
195  return (m_centre.ra_deg());
196 }
197 
198 
199 /***********************************************************************//**
200  * @brief Return circular region centre Declination
201  *
202  * @return Region centre Declination [deg].
203  *
204  * Returns the region centre Declination in degrees.
205  ***************************************************************************/
206 inline
207 double GSkyRegionCircle::dec(void) const
208 {
209  return (m_centre.dec_deg());
210 }
211 
212 #endif /* GSKYREGIONCIRCLE_HPP */
void free_members(void)
Delete class members.
std::string print(const GChatter &chatter=NORMAL) const
Print circular region.
bool overlaps(const GSkyRegion &reg) const
Checks if region is overlapping with this region.
double dec_deg(void) const
Returns Declination in degrees.
Definition: GSkyDir.hpp:256
GSkyDir m_centre
Centre or reference point of the region.
Sky direction class interface definition.
GSkyRegionCircle(void)
Void constructor.
friend bool operator!=(const GSkyRegionCircle &a, const GSkyRegionCircle &b)
Non equality operator.
void read(const std::string &line)
Read region from DS9 string.
Interface for the circular sky region class.
const double & radius(void) const
Return circular region radius (in degrees)
virtual ~GSkyRegionCircle(void)
Destructor.
std::string classname(void) const
Return class name.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
std::string write(void) const
Write region into a string.
double m_radius
Radius of circular the region (degrees)
void compute_solid_angle(void)
Compute solid angle.
double ra_deg(void) const
Returns Right Ascension in degrees.
Definition: GSkyDir.hpp:229
GChatter
Definition: GTypemaps.hpp:33
double dec(void) const
Return circular region centre Declination.
void radec_deg(const double &ra, const double &dec)
Set equatorial sky direction (degrees)
Definition: GSkyDir.cpp:224
const GSkyDir & centre(void) const
Return circular region centre.
void copy_members(const GSkyRegionCircle &region)
Copy class members.
bool contains(const GSkyDir &dir) const
Checks if sky direction lies within region.
GSkyRegionCircle & operator=(const GSkyRegionCircle &region)
Assignment operator.
Sky direction class.
Definition: GSkyDir.hpp:62
Abstract sky region base class interface definition.
friend bool operator==(const GSkyRegionCircle &a, const GSkyRegionCircle &b)
Equality operator.
Mathematical function definitions.
GSkyRegionCircle * clone(void) const
Clone circular sky region.
void clear(void)
Clear instance.
void init_members(void)
Initialise class members.
double ra(void) const
Return circular region centre Right Ascension.