Astro  v0.0.0
A C++ library for space dynamics
Loading...
Searching...
No Matches
Astro.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2 * Copyright (c) 2025, Davide Stocco and Enrico Bertolazzi. *
3 * *
4 * The Astro project is distributed under the GNU GPLv3. *
5 * *
6 * Davide Stocco Enrico Bertolazzi *
7 * University of Trento University of Trento *
8 * e-mail: davide.stocco@unitn.it e-mail: enrico.bertolazzi@unitn.it *
9\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10
11#pragma once
12
13#ifndef INCLUDE_ASTRO_HH
14#define INCLUDE_ASTRO_HH
15
16// C++ standard libraries
17#include <iostream>
18#include <tuple>
19#include <string>
20#include <cmath>
21
22// Eigen library
23#include <Eigen/Dense>
24
25// Sandals library
26#ifdef ASTRO_ENABLE_SANDALS
27 #include <Sandals/Sandals.hh>
28#endif
29
30// Print Astro errors
31#ifndef ASTRO_ERROR
32#define ASTRO_ERROR(MSG) \
33 { \
34 std::ostringstream os; \
35 os << MSG; \
36 throw std::runtime_error(os.str()); \
37 }
38#endif
39
40
41// Assert for Astro
42#ifndef ASTRO_ASSERT
43#define ASTRO_ASSERT(COND, MSG) \
44 if (!(COND)) \
45 { \
46 SANDALS_ERROR(MSG); \
47 }
48#endif
49
50// Warning for Astro
51#ifndef ASTRO_WARNING
52#define ASTRO_WARNING(MSG) \
53 { \
54 std::cout << MSG << std::endl; \
55 }
56#endif
57
58// Warning assert for Astro
59#ifndef ASTRO_ASSERT_WARNING
60#define ASTRO_ASSERT_WARNING(COND, MSG) \
61 if (!(COND)) \
62 { \
63 ASTRO_WARNING(MSG); \
64 }
65#endif
66
71namespace Astro
72{
73
74 /*\
75 | _ _ _
76 | / \ | (_) __ _ ___ ___ ___
77 | / _ \ | | |/ _` / __|/ _ \/ __|
78 | / ___ \| | | (_| \__ \ __/\__ \
79 | /_/ \_\_|_|\__,_|___/\___||___/
80 |
81 \*/
82
83 using Real = double;
84 using Size = int;
85
86 using Vector0 = Eigen::Vector<Real, 0>;
87 using Matrix0 = Eigen::Matrix<Real, 0, 0>;
88 using Vector1 = Eigen::Vector<Real, 1>;
89 using Matrix1 = Eigen::Matrix<Real, 1, 1>;
90 using Vector2 = Eigen::Vector<Real, 2>;
91 using Matrix2 = Eigen::Matrix<Real, 2, 2>;
92 using Vector3 = Eigen::Vector<Real, 3>;
93 using Matrix3 = Eigen::Matrix<Real, 3, 3>;
94 using Vector4 = Eigen::Vector<Real, 4>;
95 using Matrix4 = Eigen::Matrix<Real, 4, 4>;
96 using Vector5 = Eigen::Vector<Real, 5>;
97 using Matrix5 = Eigen::Matrix<Real, 5, 5>;
98 using Vector6 = Eigen::Vector<Real, 6>;
99 using Matrix6 = Eigen::Matrix<Real, 6, 6>;
100 using Vector7 = Eigen::Vector<Real, 7>;
101 using Matrix7 = Eigen::Matrix<Real, 7, 7>;
102 using Vector8 = Eigen::Vector<Real, 8>;
103 using Matrix8 = Eigen::Matrix<Real, 8, 8>;
104 using Vector9 = Eigen::Vector<Real, 9>;
105 using Matrix9 = Eigen::Matrix<Real, 9, 9>;
106
107 using VectorX = Eigen::Vector<Real, Eigen::Dynamic>;
108 using MatrixX = Eigen::Matrix<Real, Eigen::Dynamic, Eigen::Dynamic>;
109
110 using Scale = Eigen::DiagonalMatrix<Real, 3>;
111 using Translate = Eigen::Translation<Real, 3>;
112 using AngleAxis = Eigen::AngleAxis<Real>;
113 using Affine = Eigen::Transform<Real, 3, Eigen::Affine>;
114
115 /*\
116 | ____ _ _
117 | / ___|___ _ __ ___| |_ __ _ _ __ | |_ ___
118 | | | / _ \| '_ \/ __| __/ _` | '_ \| __/ __|
119 | | |__| (_) | | | \__ \ || (_| | | | | |_\__ \
120 | \____\___/|_| |_|___/\__\__,_|_| |_|\__|___/
121 |
122 \*/
123
124 static Real const EPSILON = std::numeric_limits<Real>::epsilon();
125 static Real const SQRT_EPSILON = std::sqrt(EPSILON);
126 static Real const CBRT_EPSILON = std::cbrt(EPSILON);
127 static Real const EPSILON_HIGH = Real(1.0e-12);
128 static Real const EPSILON_MEDIUM = Real(1.0e-10);
129 static Real const EPSILON_LOW = Real(1.0e-08);
130 static Real const INFTY = std::numeric_limits<Real>::infinity();
131 static Real const QUIET_NAN = std::numeric_limits<Real>::quiet_NaN();
132 static Real const PI = Real(3.141592653589793238462643383279502884197);
133 static Real const PIMUL2 = Real(6.283185307179586476925286766559005768394);
134 static Real const PIDIV2 = Real(1.570796326794896619231321691639751442098);
135 static Real const DEG2RAD = Real(0.017453292519943295769236907684886127134);
136 static Real const RAD2DEG = Real(57.29577951308232087679815481410517033240);
137
138 static Vector1 const NAN_VEC1 = Vector1::Constant(QUIET_NAN);
139 static Matrix1 const NAN_MAT1 = Matrix1::Constant(QUIET_NAN);
140 static Vector1 const ZEROS_VEC1 = Vector1::Zero();
141 static Matrix1 const ZEROS_MAT1 = Matrix1::Zero();
142 static Vector1 const ONES_VEC1 = Vector1::Ones();
143 static Matrix1 const ONES_MAT1 = Matrix1::Ones();
144 static Matrix1 const IDENTITY_MAT1 = Matrix1::Identity();
145
146 static Vector2 const NAN_VEC2 = Vector2::Constant(QUIET_NAN);
147 static Matrix2 const NAN_MAT2 = Matrix2::Constant(QUIET_NAN);
148 static Vector2 const ZEROS_VEC2 = Vector2::Zero();
149 static Matrix2 const ZEROS_MAT2 = Matrix2::Zero();
150 static Vector2 const ONES_VEC2 = Vector2::Ones();
151 static Matrix2 const ONES_MAT2 = Matrix2::Ones();
152 static Matrix2 const IDENTITY_MAT2 = Matrix2::Identity();
153
154 static Vector3 const NAN_VEC3 = Vector3::Constant(QUIET_NAN);
155 static Matrix3 const NAN_MAT3 = Matrix3::Constant(QUIET_NAN);
156 static Vector3 const ZEROS_VEC3 = Vector3::Zero();
157 static Matrix3 const ZEROS_MAT3 = Matrix3::Zero();
158 static Vector3 const ONES_VEC3 = Vector3::Ones();
159 static Matrix3 const ONES_MAT3 = Matrix3::Ones();
160 static Matrix3 const IDENTITY_MAT3 = Matrix3::Identity();
161
162 static Vector4 const NAN_VEC4 = Vector4::Constant(QUIET_NAN);
163 static Matrix4 const NAN_MAT4 = Matrix4::Constant(QUIET_NAN);
164 static Vector4 const ZEROS_VEC4 = Vector4::Zero();
165 static Matrix4 const ZEROS_MAT4 = Matrix4::Zero();
166 static Vector4 const ONES_VEC4 = Vector4::Ones();
167 static Matrix4 const ONES_MAT4 = Matrix4::Ones();
168 static Matrix4 const IDENTITY_MAT4 = Matrix4::Identity();
169
170 static Vector5 const NAN_VEC5 = Vector5::Constant(QUIET_NAN);
171 static Matrix5 const NAN_MAT5 = Matrix5::Constant(QUIET_NAN);
172 static Vector5 const ZEROS_VEC5 = Vector5::Zero();
173 static Matrix5 const ZEROS_MAT5 = Matrix5::Zero();
174 static Vector5 const ONES_VEC5 = Vector5::Ones();
175 static Matrix5 const ONES_MAT5 = Matrix5::Ones();
176 static Matrix5 const IDENTITY_MAT5 = Matrix5::Identity();
177
178 static Vector6 const NAN_VEC6 = Vector6::Constant(QUIET_NAN);
179 static Matrix6 const NAN_MAT6 = Matrix6::Constant(QUIET_NAN);
180 static Vector6 const ZEROS_VEC6 = Vector6::Zero();
181 static Matrix6 const ZEROS_MAT6 = Matrix6::Zero();
182 static Vector6 const ONES_VEC6 = Vector6::Ones();
183 static Matrix6 const ONES_MAT6 = Matrix6::Ones();
184 static Matrix6 const IDENTITY_MAT6 = Matrix6::Identity();
185
186 static Vector7 const NAN_VEC7 = Vector7::Constant(QUIET_NAN);
187 static Matrix7 const NAN_MAT7 = Matrix7::Constant(QUIET_NAN);
188 static Vector7 const ZEROS_VEC7 = Vector7::Zero();
189 static Matrix7 const ZEROS_MAT7 = Matrix7::Zero();
190 static Vector7 const ONES_VEC7 = Vector7::Ones();
191 static Matrix7 const ONES_MAT7 = Matrix7::Ones();
192 static Matrix7 const IDENTITY_MAT7 = Matrix7::Identity();
193
194 static Vector8 const NAN_VEC8 = Vector8::Constant(QUIET_NAN);
195 static Matrix8 const NAN_MAT8 = Matrix8::Constant(QUIET_NAN);
196 static Vector8 const ZEROS_VEC8 = Vector8::Zero();
197 static Matrix8 const ZEROS_MAT8 = Matrix8::Zero();
198 static Vector8 const ONES_VEC8 = Vector8::Ones();
199 static Matrix8 const ONES_MAT8 = Matrix8::Ones();
200 static Matrix8 const IDENTITY_MAT8 = Matrix8::Identity();
201
202 static Vector9 const NAN_VEC9 = Vector9::Constant(QUIET_NAN);
203 static Matrix9 const NAN_MAT9 = Matrix9::Constant(QUIET_NAN);
204 static Vector9 const ZEROS_VEC9 = Vector9::Zero();
205 static Matrix9 const ZEROS_MAT9 = Matrix9::Zero();
206 static Vector9 const ONES_VEC9 = Vector9::Ones();
207 static Matrix9 const ONES_MAT9 = Matrix9::Ones();
208 static Matrix9 const IDENTITY_MAT9 = Matrix9::Identity();
209
210} // namespace Astro
211
212// Utility functions
213#include "Astro/Utilities.hxx"
214
215#endif // INCLUDE_ASTRO_HH
The namespace for the Astro library.
static Vector3 const ZEROS_VEC3
Zeros vector static constant object.
Definition Astro.hh:156
static Vector9 const NAN_VEC9
Not-a-number vector static constant object.
Definition Astro.hh:202
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > MatrixX
matrix of Real number type.
Definition Astro.hh:108
static Vector8 const NAN_VEC8
Not-a-number vector static constant object.
Definition Astro.hh:194
static Real const PI
Pi static constant value.
Definition Astro.hh:132
static Vector7 const NAN_VEC7
Not-a-number vector static constant object.
Definition Astro.hh:186
static Matrix2 const IDENTITY_MAT2
Identity matrix static constant object.
Definition Astro.hh:152
static Vector5 const ONES_VEC5
Ones vector static constant object.
Definition Astro.hh:174
static Matrix2 const ONES_MAT2
Ones matrix static constant object.
Definition Astro.hh:151
Eigen::Matrix< Real, 3, 3 > Matrix3
matrix of Real number type.
Definition Astro.hh:93
static Real const EPSILON_HIGH
High precision epsilon static constant value.
Definition Astro.hh:127
static Vector6 const ZEROS_VEC6
Zeros vector static constant object.
Definition Astro.hh:180
static Matrix1 const ZEROS_MAT1
Zeros matrix static constant object.
Definition Astro.hh:141
Eigen::Matrix< Real, 0, 0 > Matrix0
matrix of Real number type.
Definition Astro.hh:87
static Matrix8 const NAN_MAT8
Not-a-number matrix static constant object.
Definition Astro.hh:195
Eigen::Matrix< Real, 7, 7 > Matrix7
matrix of Real number type.
Definition Astro.hh:101
static Vector9 const ONES_VEC9
Ones vector static constant object.
Definition Astro.hh:206
int Size
Size number type.
Definition Astro.hh:84
static Matrix4 const ZEROS_MAT4
Zeros matrix static constant object.
Definition Astro.hh:165
Eigen::Vector< Real, 5 > Vector5
vector of Real number type (column vector).
Definition Astro.hh:96
static Vector1 const ZEROS_VEC1
Zeros vector static constant object.
Definition Astro.hh:140
static Matrix6 const NAN_MAT6
Not-a-number matrix static constant object.
Definition Astro.hh:179
static Real const EPSILON
Machine epsilon epsilon static constant value.
Definition Astro.hh:124
Eigen::Transform< Real, 3, Eigen::Affine > Affine
3D affine transformation type.
Definition Astro.hh:113
static Matrix7 const NAN_MAT7
Not-a-number matrix static constant object.
Definition Astro.hh:187
static Vector4 const ONES_VEC4
Ones vector static constant object.
Definition Astro.hh:166
static Real const CBRT_EPSILON
Cubic root of machine epsilon epsilon static constant value.
Definition Astro.hh:126
static Vector9 const ZEROS_VEC9
Zeros vector static constant object.
Definition Astro.hh:204
static Vector6 const ONES_VEC6
Ones vector static constant object.
Definition Astro.hh:182
Eigen::AngleAxis< Real > AngleAxis
3D rotation transformation type.
Definition Astro.hh:112
static Vector3 const NAN_VEC3
Not-a-number vector static constant object.
Definition Astro.hh:154
Eigen::Vector< Real, 0 > Vector0
vector of Real number type (column vector).
Definition Astro.hh:86
static Matrix7 const ZEROS_MAT7
Zeros matrix static constant object.
Definition Astro.hh:189
static Matrix6 const ONES_MAT6
Ones matrix static constant object.
Definition Astro.hh:183
static Real const SQRT_EPSILON
Square root of machine epsilon epsilon static constant value.
Definition Astro.hh:125
static Matrix1 const IDENTITY_MAT1
Identity matrix static constant object.
Definition Astro.hh:144
static Vector5 const ZEROS_VEC5
Zeros vector static constant object.
Definition Astro.hh:172
static Real const EPSILON_LOW
Low precision epsilon static constant value.
Definition Astro.hh:129
static Matrix3 const NAN_MAT3
Not-a-number matrix static constant object.
Definition Astro.hh:155
static Real const QUIET_NAN
Not-a-number static constant value.
Definition Astro.hh:131
static Matrix4 const ONES_MAT4
Ones matrix static constant object.
Definition Astro.hh:167
static Matrix9 const ZEROS_MAT9
Zeros matrix static constant object.
Definition Astro.hh:205
static Matrix1 const ONES_MAT1
Ones matrix static constant object.
Definition Astro.hh:143
static Vector4 const ZEROS_VEC4
Zeros vector static constant object.
Definition Astro.hh:164
static Real const RAD2DEG
The value of .
Definition Astro.hh:136
Eigen::Vector< Real, 6 > Vector6
vector of Real number type (column vector).
Definition Astro.hh:98
static Matrix8 const ZEROS_MAT8
Zeros matrix static constant object.
Definition Astro.hh:197
static Matrix3 const ZEROS_MAT3
Zeros matrix static constant object.
Definition Astro.hh:157
static Matrix2 const ZEROS_MAT2
Zeros matrix static constant object.
Definition Astro.hh:149
static Vector4 const NAN_VEC4
Not-a-number vector static constant object.
Definition Astro.hh:162
static Real const DEG2RAD
The value of .
Definition Astro.hh:135
Eigen::Vector< Real, 1 > Vector1
vector of Real number type (column vector).
Definition Astro.hh:88
static Matrix4 const NAN_MAT4
Not-a-number matrix static constant object.
Definition Astro.hh:163
Eigen::Vector< Real, 4 > Vector4
vector of Real number type (column vector).
Definition Astro.hh:94
Eigen::Matrix< Real, 1, 1 > Matrix1
matrix of Real number type.
Definition Astro.hh:89
static Matrix7 const ONES_MAT7
Ones matrix static constant object.
Definition Astro.hh:191
static Matrix5 const IDENTITY_MAT5
Identity matrix static constant object.
Definition Astro.hh:176
double Real
Real number type.
Definition Astro.hh:83
static Matrix9 const ONES_MAT9
Ones matrix static constant object.
Definition Astro.hh:207
Eigen::Vector< Real, 9 > Vector9
vector of Real number type (column vector).
Definition Astro.hh:104
Eigen::Matrix< Real, 6, 6 > Matrix6
matrix of Real number type.
Definition Astro.hh:99
Eigen::Matrix< Real, 5, 5 > Matrix5
matrix of Real number type.
Definition Astro.hh:97
Eigen::Vector< Real, 2 > Vector2
vector of Real number type (column vector).
Definition Astro.hh:90
static Matrix3 const ONES_MAT3
Ones matrix static constant object.
Definition Astro.hh:159
static Vector8 const ONES_VEC8
Ones vector static constant object.
Definition Astro.hh:198
static Vector2 const ONES_VEC2
Ones vector static constant object.
Definition Astro.hh:150
static Matrix5 const ONES_MAT5
Ones matrix static constant object.
Definition Astro.hh:175
static Matrix9 const IDENTITY_MAT9
Identity matrix static constant object.
Definition Astro.hh:208
static Vector8 const ZEROS_VEC8
Zeros vector static constant object.
Definition Astro.hh:196
static Vector1 const NAN_VEC1
Not-a-number vector static constant object.
Definition Astro.hh:138
static Vector5 const NAN_VEC5
Not-a-number vector static constant object.
Definition Astro.hh:170
Eigen::Vector< Real, 3 > Vector3
vector of Real number type (column vector).
Definition Astro.hh:92
Eigen::Vector< Real, 8 > Vector8
vector of Real number type (column vector).
Definition Astro.hh:102
static Matrix5 const NAN_MAT5
Not-a-number matrix static constant object.
Definition Astro.hh:171
static Matrix9 const NAN_MAT9
Not-a-number matrix static constant object.
Definition Astro.hh:203
static Vector6 const NAN_VEC6
Not-a-number vector static constant object.
Definition Astro.hh:178
Eigen::DiagonalMatrix< Real, 3 > Scale
3D scaling transformation type.
Definition Astro.hh:110
static Vector7 const ONES_VEC7
Ones vector static constant object.
Definition Astro.hh:190
static Real const INFTY
Infinity static constant value.
Definition Astro.hh:130
static Vector1 const ONES_VEC1
Ones vector static constant object.
Definition Astro.hh:142
static Matrix8 const IDENTITY_MAT8
Identity matrix static constant object.
Definition Astro.hh:200
static Matrix2 const NAN_MAT2
Not-a-number matrix static constant object.
Definition Astro.hh:147
static Matrix6 const IDENTITY_MAT6
Identity matrix static constant object.
Definition Astro.hh:184
static Matrix8 const ONES_MAT8
Ones matrix static constant object.
Definition Astro.hh:199
Eigen::Matrix< Real, 8, 8 > Matrix8
matrix of Real number type.
Definition Astro.hh:103
static Vector2 const NAN_VEC2
Not-a-number vector static constant object.
Definition Astro.hh:146
static Real const PIMUL2
The value of .
Definition Astro.hh:133
static Vector3 const ONES_VEC3
Ones vector static constant object.
Definition Astro.hh:158
static Real const EPSILON_MEDIUM
Medium precision epsilon static constant value.
Definition Astro.hh:128
static Matrix4 const IDENTITY_MAT4
Identity matrix static constant object.
Definition Astro.hh:168
static Matrix5 const ZEROS_MAT5
Zeros matrix static constant object.
Definition Astro.hh:173
Eigen::Matrix< Real, 2, 2 > Matrix2
matrix of Real number type.
Definition Astro.hh:91
Eigen::Vector< Real, Eigen::Dynamic > VectorX
vector of Real number type (column vector).
Definition Astro.hh:107
static Matrix3 const IDENTITY_MAT3
Identity matrix static constant object.
Definition Astro.hh:160
static Vector7 const ZEROS_VEC7
Zeros vector static constant object.
Definition Astro.hh:188
Eigen::Matrix< Real, 4, 4 > Matrix4
matrix of Real number type.
Definition Astro.hh:95
static Matrix6 const ZEROS_MAT6
Zeros matrix static constant object.
Definition Astro.hh:181
Eigen::Matrix< Real, 9, 9 > Matrix9
matrix of Real number type.
Definition Astro.hh:105
Eigen::Translation< Real, 3 > Translate
3D translation transformation type.
Definition Astro.hh:111
static Matrix7 const IDENTITY_MAT7
Identity matrix static constant object.
Definition Astro.hh:192
static Matrix1 const NAN_MAT1
Not-a-number matrix static constant object.
Definition Astro.hh:139
static Vector2 const ZEROS_VEC2
Zeros vector static constant object.
Definition Astro.hh:148
static Real const PIDIV2
The value of .
Definition Astro.hh:134
Eigen::Vector< Real, 7 > Vector7
vector of Real number type (column vector).
Definition Astro.hh:100