GammaLib 2.0.0
Loading...
Searching...
No Matches
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 ***************************************************************************/
52class 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
58public:
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
86private:
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 ***************************************************************************/
103inline
104std::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 ***************************************************************************/
115inline
116double 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 ***************************************************************************/
127inline
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 ***************************************************************************/
139inline
140const 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 ***************************************************************************/
151inline
152double 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 ***************************************************************************/
163inline
164const 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 ***************************************************************************/
175inline
176double GHorizDir::az_deg() const
177{
178 return (m_az * gammalib::rad2deg);
179}
180
181#endif /* GHORIZDIR_HPP */
Definition of interface for all GammaLib classes.
Mathematical function definitions.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Vector class interface definition.
Interface class for all GammaLib classes.
Definition GBase.hpp:52
Horizontal (Alt/Az) direction class.
Definition GHorizDir.hpp:52
void clear(void)
Clear horizontal direction.
void rotate_deg(const double &phi, const double &theta)
Rotate horizontal direction by zenith and azimuth angle.
GHorizDir * clone(void) const
Clone horizontal direction.
double dist_deg(const GHorizDir &dir) const
Compute angular distance to horizontal direction in degrees.
double zenith_deg(void) const
Return zenith angle in degrees.
GVector celvector(void) const
Return horizontal direction as 3D vector.
double az_deg(void) const
Return azimuth angle in degrees.
void copy_members(const GHorizDir &dir)
Copy class members.
void init_members(void)
Initialise class members.
double m_az
azimuth in radians
Definition GHorizDir.hpp:94
double alt_deg(void) const
Return altitude angle in degrees.
void free_members(void)
Delete class members.
GHorizDir & operator=(const GHorizDir &dir)
Assignment operator.
double dist(const GHorizDir &dir) const
Compute angular distance to horizontal direction in radians.
GHorizDir(void)
Constructor.
Definition GHorizDir.cpp:59
const double & az(void) const
Return azimuth angle in radians.
void altaz(const double &alt, const double &az)
Set horizontal direction (radians)
const double & alt(void) const
Return altitude angle in radians.
double zenith(void) const
Return zenith angle in radians.
friend bool operator==(const GHorizDir &a, const GHorizDir &b)
Equality operator.
friend bool operator!=(const GHorizDir &a, const GHorizDir &b)
Non equality operator.
std::string classname(void) const
Return class name.
std::string print(const GChatter &chatter=NORMAL) const
Print horizontal direction information.
virtual ~GHorizDir(void)
Destructor.
Definition GHorizDir.cpp:90
double m_alt
altitude in radians
Definition GHorizDir.hpp:93
void altaz_deg(const double &alt, const double &az)
Set horizontal direction (degrees)
Vector class.
Definition GVector.hpp:46
const double pihalf
Definition GMath.hpp:38
const double rad2deg
Definition GMath.hpp:44