-
Notifications
You must be signed in to change notification settings - Fork 0
/
VSOP.hpp
216 lines (157 loc) · 4.65 KB
/
VSOP.hpp
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#ifndef LOUIERIKSSON_VSOP_HPP
#define LOUIERIKSSON_VSOP_HPP
#include <glm/detail/qualifier.hpp>
#include <vsop87a_full.h>
namespace LouiEriksson {
/**
* @mainpage Version 1.0.0
*
* @brief Class representing the VSOP astronomical coordinate system.
*
* The VSOP class provides functions for obtaining position information of celestial bodies.
*
* @tparam T The underlying type of the vector components.
* @tparam Q The precision of the vector components.
*/
template <typename T, glm::precision Q>
struct VSOP final {
private:
/**
* @brief Changes the handedness of a 3D vector.
*
* This function takes a 3D vector and returns a new vector with changed handedness.
*
* @tparam T The underlying type of the vector components.
* @tparam P The precision of the vector components.
* @param[in] _vec The input vector.
* @return The new vector with changed handedness.
*/
template<typename T, glm::precision Q>
static constexpr glm::vec<3, T, Q> ChangeHandedness(const glm::vec<3, T, Q>& _vec) {
return { -_vec.x, _vec.z, _vec.y };
}
public:
struct Position final {
private:
glm::vec<3, T, Q> m_Spherical;
glm::vec<3, T, Q> m_Cartesian;
glm::qua< T, Q> m_Rotation;
public:
constexpr const glm::vec<3, T, Q>& Spherical() const noexcept { return m_Spherical; }
constexpr const glm::vec<3, T, Q>& Cartesian() const noexcept { return m_Cartesian; }
constexpr const glm::qua< T, Q>& Rotation() const noexcept { return m_Rotation; }
constexpr Position(const glm::vec<3, T, Q>& _spherical, const glm::vec<3, T, Q>& _cartesian, const glm::vec<3, T, Q>& _rotation) noexcept :
m_Spherical(_spherical),
m_Cartesian(_cartesian),
m_Rotation (_rotation ) {}
constexpr Position() noexcept :
m_Spherical{},
m_Cartesian{},
m_Rotation {} {}
};
struct V87 final {
struct A final {
static Position GetSol() {
return {
{},
{ 0.0, 0.0, 0.0 },
{}
};
}
static Position GetMercury(const double& _time) {
double tmp[3];
vsop87a_full::getMercury(_time, tmp);
return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}
static Position GetVenus(const double& _time) {
double tmp[3];
vsop87a_full::getVenus(_time, tmp);
return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}
static Position GetEarth(const double& _time) {
double tmp[3];
vsop87a_full::getEarth(_time, tmp);
return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}
static Position GetEMB(const double& _time) {
double tmp[3];
vsop87a_full::getEmb(_time, tmp);
return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}
static Position GetMoon(const Position& _earth, const Position& _emb) {
auto e1 = ChangeHandedness<double, Q>(_earth.Cartesian());
auto e2 = ChangeHandedness<double, Q>( _emb.Cartesian());
double tmp[3];
vsop87a_full::getMoon(&e1[0], &e2[0], tmp);
return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{},
};
}
static Position GetMars(const double& _time) {
double tmp[3];
vsop87a_full::getMars(_time, tmp);
return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}
static Position GetJupiter(const double& _time) {
double tmp[3];
vsop87a_full::getJupiter(_time, tmp);
return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}
static Position GetSaturn(const double& _time) {
double tmp[3];
vsop87a_full::getSaturn(_time, tmp);
return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}
static Position GetUranus(const double& _time) {
double tmp[3];
vsop87a_full::getUranus(_time, tmp);
return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}
static Position GetNeptune(const double& _time) {
double tmp[3];
vsop87a_full::getNeptune(_time, tmp);
return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}
};
};
};
} // LouiEriksson
#endif //LOUIERIKSSON_VSOP_HPP