GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GHorizDir.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GHorizDir.hpp - Horizontal direction class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2014 by Karl Kosack *
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 GHorizDir.hpp
23  * @brief Horizontal direction class interface definition
24  * @author Karl Kosack
25  */
26 
27 #ifndef GHORIZDIR_HPP
28 #define GHORIZDIR_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 #include "GVector.hpp"
34 #include "GMath.hpp"
35 
36 /* __ Compile options ____________________________________________________ */
37 
38 
39 /***********************************************************************//**
40  * @class GHorizDir
41  *
42  * @brief Horizontal (Alt/Az) direction class
43  *
44  * This class is essentially a copy of GSkyDir and implements a
45  * spherical coordinate on the sky, in horizontal coordinates as seen
46  * from Earth.
47  *
48  * @note since this class shares much functionality with GSkyDir, a
49  * common base-class should probably be created in the future to avoid
50  * duplication of code.
51  ***************************************************************************/
52 class GHorizDir : public GBase {
53 
54  // Operator friends
55  friend bool operator==(const GHorizDir &a, const GHorizDir &b);
56  friend bool operator!=(const GHorizDir &a, const GHorizDir &b);
57 
58 public:
59  // Constructors and destructors
60  GHorizDir(void);
61  GHorizDir(const GHorizDir& dir);
62  virtual ~GHorizDir(void);
63 
64  // Operators
65  GHorizDir& operator=(const GHorizDir& dir);
66 
67  // Methods
68  void clear(void);
69  GHorizDir* clone(void) const;
70  std::string classname(void) const;
71  void altaz(const double& alt, const double& az);
72  void altaz_deg(const double& alt, const double& az);
73  void celvector(const GVector& vector);
74  void rotate_deg(const double& phi, const double& theta);
75  const double& alt(void) const;
76  const double& az(void) const;
77  double zenith(void) const;
78  double zenith_deg(void) const;
79  double alt_deg(void) const;
80  double az_deg(void) const;
81  GVector celvector(void) const;
82  double dist(const GHorizDir& dir) const;
83  double dist_deg(const GHorizDir& dir) const;
84  std::string print(const GChatter& chatter = NORMAL) const;
85 
86 private:
87  // Private methods
88  void init_members(void);
89  void copy_members(const GHorizDir& dir);
90  void free_members(void);
91 
92  // Private members
93  double m_alt; //!< altitude in radians
94  double m_az; //!< azimuth in radians
95 };
96 
97 
98 /***********************************************************************//**
99  * @brief Return class name
100  *
101  * @return String containing the class name ("GHorizDir").
102  ***************************************************************************/
103 inline
104 std::string GHorizDir::classname(void) const
105 {
106  return ("GHorizDir");
107 }
108 
109 
110 /***********************************************************************//**
111  * @brief Return zenith angle in radians
112  *
113  * @return zenith angle in radians.
114  ***************************************************************************/
115 inline
116 double GHorizDir::zenith() const
117 {
118  return (gammalib::pihalf - m_alt);
119 }
120 
121 
122 /***********************************************************************//**
123  * @brief Return zenith angle in degrees
124  *
125  * @return zenith angle in degrees.
126  ***************************************************************************/
127 inline
128 double GHorizDir::zenith_deg() const
129 {
130  return (zenith() * gammalib::rad2deg);
131 }
132 
133 
134 /***********************************************************************//**
135  * @brief Return altitude angle in radians
136  *
137  * @return Altitude angle in radians.
138  ***************************************************************************/
139 inline
140 const double& GHorizDir::alt() const
141 {
142  return m_alt;
143 }
144 
145 
146 /***********************************************************************//**
147  * @brief Return altitude angle in degrees
148  *
149  * @return Altitude angle in degrees.
150  ***************************************************************************/
151 inline
152 double GHorizDir::alt_deg() const
153 {
154  return (m_alt * gammalib::rad2deg);
155 }
156 
157 
158 /***********************************************************************//**
159  * @brief Return azimuth angle in radians
160  *
161  * @return Azimuth angle in radians.
162  ***************************************************************************/
163 inline
164 const double& GHorizDir::az() const
165 {
166  return m_az;
167 }
168 
169 
170 /***********************************************************************//**
171  * @brief Return azimuth angle in degrees
172  *
173  * @return Azimuth angle in degrees.
174  ***************************************************************************/
175 inline
176 double GHorizDir::az_deg() const
177 {
178  return (m_az * gammalib::rad2deg);
179 }
180 
181 #endif /* GHORIZDIR_HPP */
const double & alt(void) const
Return altitude angle in radians.
Definition: GHorizDir.hpp:140
void rotate_deg(const double &phi, const double &theta)
Rotate horizontal direction by zenith and azimuth angle.
Definition: GHorizDir.cpp:244
void clear(void)
Clear horizontal direction.
Definition: GHorizDir.cpp:142
void free_members(void)
Delete class members.
Definition: GHorizDir.cpp:401
Definition of interface for all GammaLib classes.
double m_az
azimuth in radians
Definition: GHorizDir.hpp:94
Horizontal (Alt/Az) direction class.
Definition: GHorizDir.hpp:52
friend bool operator==(const GHorizDir &a, const GHorizDir &b)
Equality operator.
Definition: GHorizDir.cpp:425
GHorizDir & operator=(const GHorizDir &dir)
Assignment operator.
Definition: GHorizDir.cpp:112
friend bool operator!=(const GHorizDir &a, const GHorizDir &b)
Non equality operator.
Definition: GHorizDir.cpp:449
double alt_deg(void) const
Return altitude angle in degrees.
Definition: GHorizDir.hpp:152
const double pihalf
Definition: GMath.hpp:38
virtual ~GHorizDir(void)
Destructor.
Definition: GHorizDir.cpp:90
GHorizDir(void)
Constructor.
Definition: GHorizDir.cpp:59
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
GChatter
Definition: GTypemaps.hpp:33
void copy_members(const GHorizDir &dir)
Copy class members.
Definition: GHorizDir.cpp:387
double dist(const GHorizDir &dir) const
Compute angular distance to horizontal direction in radians.
Definition: GHorizDir.cpp:305
Vector class interface definition.
std::string classname(void) const
Return class name.
Definition: GHorizDir.hpp:104
double az_deg(void) const
Return azimuth angle in degrees.
Definition: GHorizDir.hpp:176
std::string print(const GChatter &chatter=NORMAL) const
Print horizontal direction information.
Definition: GHorizDir.cpp:343
GHorizDir * clone(void) const
Clone horizontal direction.
Definition: GHorizDir.cpp:160
void altaz_deg(const double &alt, const double &az)
Set horizontal direction (degrees)
Definition: GHorizDir.cpp:195
void init_members(void)
Initialise class members.
Definition: GHorizDir.cpp:371
void altaz(const double &alt, const double &az)
Set horizontal direction (radians)
Definition: GHorizDir.cpp:175
double dist_deg(const GHorizDir &dir) const
Compute angular distance to horizontal direction in degrees.
Definition: GHorizDir.cpp:329
GVector celvector(void) const
Return horizontal direction as 3D vector.
Definition: GHorizDir.cpp:282
double m_alt
altitude in radians
Definition: GHorizDir.hpp:93
const double & az(void) const
Return azimuth angle in radians.
Definition: GHorizDir.hpp:164
double zenith_deg(void) const
Return zenith angle in degrees.
Definition: GHorizDir.hpp:128
Vector class.
Definition: GVector.hpp:46
const double rad2deg
Definition: GMath.hpp:44
Mathematical function definitions.
double zenith(void) const
Return zenith angle in radians.
Definition: GHorizDir.hpp:116