GammaLib  1.7.0.dev
 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-2015 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 public:
61  // Constructors and destructors
62  GSkyRegionCircle(void);
63  GSkyRegionCircle(const GSkyDir& centre, const double& radius);
64  GSkyRegionCircle(const double& ra, const double& dec, const double& radius);
65  explicit GSkyRegionCircle(const std::string& line);
66  GSkyRegionCircle(const GSkyRegionCircle& region);
67  virtual ~GSkyRegionCircle(void);
68 
69  // Operators
71 
72  // Implemented methods
73  void clear(void);
74  GSkyRegionCircle* clone(void) const;
75  std::string classname(void) const;
76  const double& radius(void) const;
77  void radius(const double& radius);
78  const GSkyDir& centre(void) const;
79  void centre(const GSkyDir& centre);
80  void centre(const double& ra,const double& dec);
81  double ra(void) const;
82  double dec(void) const;
83  void read(const std::string& line);
84  std::string write(void) const;
85  bool contains(const GSkyDir& dir) const;
86  bool contains(const GSkyRegion& reg) const;
87  bool overlaps(const GSkyRegion& reg) const;
88  std::string print(const GChatter& chatter = NORMAL) const;
89 
90 protected:
91  // Protected methods
92  void init_members(void);
93  void copy_members(const GSkyRegionCircle& region);
94  void free_members(void);
95  void compute_solid_angle(void);
96 
97  // Protected members
98  GSkyDir m_centre; //!< Centre or reference point of the region
99  double m_radius; //!< Radius of circular the region [deg]
100 };
101 
102 
103 /***********************************************************************//**
104  * @brief Return class name
105  *
106  * @return String containing the class name ("GSkyRegionCircle").
107  ***************************************************************************/
108 inline
109 std::string GSkyRegionCircle::classname(void) const
110 {
111  return ("GSkyRegionCircle");
112 }
113 
114 
115 /***********************************************************************//**
116  * @brief Return circular region radius (in degrees)
117  *
118  * @return Region radius [deg].
119  *
120  * Returns the region radius in degrees.
121  ***************************************************************************/
122 inline
123 const double& GSkyRegionCircle::radius(void) const
124 {
125  return (m_radius);
126 }
127 
128 
129 /***********************************************************************//**
130  * @brief Return circular region centre
131  *
132  * @return Region centre.
133  *
134  * Returns the region centre.
135  ***************************************************************************/
136 inline
138 {
139  return (m_centre);
140 }
141 
142 
143 /***********************************************************************//**
144  * @brief Set circular region centre
145  *
146  * @param[in] dir Region centre.
147  *
148  * Sets the centre of the circular region to the specified sky direction.
149  ***************************************************************************/
150 inline
152 {
153  // Set centre
154  m_centre = dir;
155 
156  // Return
157  return;
158 }
159 
160 
161 /***********************************************************************//**
162  * @brief Set circular region centre Right Ascension and Declincation
163  *
164  * @param[in] ra Right Ascension [deg].
165  * @param[in] dec Declination [deg].
166  *
167  * Sets the centre of the circular region to the specified Right Ascension
168  * and Declination.
169  ***************************************************************************/
170 inline
171 void GSkyRegionCircle::centre(const double& ra, const double& dec)
172 {
173  // Set centre values
174  m_centre.radec_deg(ra,dec);
175 
176  // Return
177  return;
178 }
179 
180 
181 /***********************************************************************//**
182  * @brief Return circular region centre Right Ascension
183  *
184  * @return Region centre Right Ascension [deg].
185  *
186  * Returns the region centre Right Ascension in degrees.
187  ***************************************************************************/
188 inline
189 double GSkyRegionCircle::ra(void) const
190 {
191  return (m_centre.ra_deg());
192 }
193 
194 
195 /***********************************************************************//**
196  * @brief Return circular region centre Declination
197  *
198  * @return Region centre Declination [deg].
199  *
200  * Returns the region centre Declination in degrees.
201  ***************************************************************************/
202 inline
203 double GSkyRegionCircle::dec(void) const
204 {
205  return (m_centre.dec_deg());
206 }
207 
208 #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:250
GSkyDir m_centre
Centre or reference point of the region.
Sky direction class interface definition.
GSkyRegionCircle(void)
Void constructor.
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 [deg].
void compute_solid_angle(void)
Compute solid angle.
double ra_deg(void) const
Returns Right Ascension in degrees.
Definition: GSkyDir.hpp:223
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:202
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.
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.