GHorizDir.hpp
4.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/***************************************************************************
* GHorizDir.hpp - Horizontal direction class *
* ----------------------------------------------------------------------- *
* copyright (C) 2008-2013 by Juergen Knoedlseder *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
***************************************************************************/
/**
* @file GHorizDir.hpp
* @brief Horizontal direction class interface definition
* @author K. Kosack
*/
#ifndef GHORIZDIR_HPP
#define GHORIZDIR_HPP
/* __ Includes ___________________________________________________________ */
#include <string>
#include "GBase.hpp"
#include "GVector.hpp"
#include "GMath.hpp"
/* __ Compile options ____________________________________________________ */
#define G_SINCOS_CACHE
/***********************************************************************//**
* @class GHorizDir
*
* @brief Horizontal (Alt/Az) direction class
*
* This class is essentially a copy of GSkyDir and implements a
* spherical coordinate on the sky, in horizontal coordinates as seen
* from Earth.
*
* @note since this class shares much functionality with GSkyDir, a
* common base-class should probably be created in the future to avoid
* duplication of code.
***************************************************************************/
class GHorizDir : public GBase {
// Operator friends
friend bool operator==(const GHorizDir &a, const GHorizDir &b);
friend bool operator!=(const GHorizDir &a, const GHorizDir &b);
public:
// Constructors and destructors
GHorizDir(void);
GHorizDir(const GHorizDir& dir);
virtual ~GHorizDir(void);
// Operators
GHorizDir& operator= (const GHorizDir& dir);
// Methods
void clear(void);
GHorizDir* clone(void) const;
void altaz(const double& alt, const double& az);
void altaz_deg(const double& alt, const double& az);
void celvector(const GVector& vector);
void rotate_deg(const double& phi, const double& theta);
const double& alt(void) const { return m_alt; }
const double& az(void) const { return m_az; }
double zenith(void) const;
double zenith_deg(void) const;
double alt_deg(void) const;
double az_deg(void) const;
GVector celvector(void) const;
double dist(const GHorizDir& dir) const;
double dist_deg(const GHorizDir& dir) const;
std::string print(const GChatter& chatter = NORMAL) const;
private:
// Private methods
void init_members(void);
void copy_members(const GHorizDir& dir);
void free_members(void);
// Private members
double m_alt; //!< altitude in radians
double m_az; //!< azimuth in radians
// Sincos cache
// #if defined(G_SINCOS_CACHE)
// mutable bool m_has_lb_cache;
// mutable bool m_has_radec_cache;
// mutable double m_sin_b;
// mutable double m_cos_b;
// mutable double m_sin_dec;
// mutable double m_cos_dec;
// #endif
};
/***********************************************************************//**
* @brief Return zenith angle in radians
*
* @return zenith angle in radians
***************************************************************************/
inline
double GHorizDir::zenith() const
{
return gammalib::pihalf - m_alt;
};
/***********************************************************************//**
* @brief Return zenith angle in radians
*
* @return zenith angle in radians
***************************************************************************/
inline
double GHorizDir::zenith_deg() const
{
return zenith() * gammalib::rad2deg;
}
inline
double GHorizDir::alt_deg() const
{
return m_alt * gammalib::rad2deg;
}
inline
double GHorizDir::az_deg() const
{
return m_az * gammalib::rad2deg;
}
#endif /* GHORIZDIR_HPP */