Antkeeper  0.0.1
elements.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_PHYSICS_ORBIT_ELEMENTS_HPP
21 #define ANTKEEPER_PHYSICS_ORBIT_ELEMENTS_HPP
22 
23 #include <engine/math/vector.hpp>
24 #include <engine/math/numbers.hpp>
25 #include <cmath>
26 
27 namespace physics {
28 namespace orbit {
29 
35 template <class T>
36 struct elements
37 {
39  typedef T scalar_type;
40 
43 
46 
49 
52 
55 
58 };
59 
67 template <class T>
68 T period(T a, T gm);
69 
77 template <class T>
78 T mean_motion(T a, T gm);
79 
86 template <class T>
87 T mean_motion(T t);
88 
96 template <class T>
97 T argument_periapsis(T om, T lp);
98 
106 template <class T>
107 T longitude_periapsis(T om, T w);
108 
116 template <class T>
117 T semiminor_axis(T a, T ec);
118 
126 template <class T>
127 T semilatus_rectum(T a, T ec);
128 
129 template <class T>
130 T period(T a, T gm)
131 {
132  return math::two_pi<T> * std::sqrt((a * a * a) / gm);
133 }
134 
135 template <class T>
136 T mean_motion(T a, T gm)
137 {
138  return std::sqrt((a * a * a) / gm);
139 }
140 
141 template <class T>
143 {
144  return math::two_pi<T> / t;
145 }
146 
147 template <class T>
148 T argument_periapsis(T om, T lp)
149 {
150  return lp - om;
151 }
152 
153 template <class T>
155 {
156  return w + om;
157 }
158 
159 template <class T>
160 T semiminor_axis(T a, T ec)
161 {
162  return a * std::sqrt(T(1) - ec * ec);
163 }
164 
165 template <class T>
166 T semilatus_rectum(T a, T ec)
167 {
168  return a * (T(1) - ec * ec);
169 }
170 
171 } // namespace orbit
172 } // namespace physics
173 
174 #endif // ANTKEEPER_PHYSICS_ORBIT_ELEMENTS_HPP
vector< T, N > sqrt(const vector< T, N > &x)
Takes the square root of each element.
T period(T a, T gm)
Calculates the period of an elliptical orbit according to Kepler's third law.
Definition: elements.hpp:130
T semilatus_rectum(T a, T ec)
Derives the semi-latus rectum (l) of an orbit, given the semimajor axis (a) and eccentricity (e).
Definition: elements.hpp:166
T argument_periapsis(T om, T lp)
Derives the argument of the periapsis (omega) of an orbit, given the longitude of periapsis (pomega) ...
Definition: elements.hpp:148
T semiminor_axis(T a, T ec)
Derives the semiminor axis (b) of an orbit, given the semimajor axis (a) and eccentricity (e).
Definition: elements.hpp:160
T longitude_periapsis(T om, T w)
Derives the longitude of the periapsis (pomega) of an orbit, given the argument of periapsis (omega) ...
Definition: elements.hpp:154
T mean_motion(T a, T gm)
Calculates the mean motion (n) of an orbit.
Definition: elements.hpp:136
Physics.
Definition: constants.hpp:23
Set of six Keplerian elements required to uniquely identify an orbit.
Definition: elements.hpp:37
scalar_type ec
Eccentricity (e).
Definition: elements.hpp:42
scalar_type ma
Mean anomaly (M) at epoch, in radians.
Definition: elements.hpp:57
scalar_type a
Semimajor axis (a).
Definition: elements.hpp:45
T scalar_type
Scalar type.
Definition: elements.hpp:39
scalar_type om
Right ascension of the ascending node (OMEGA), in radians.
Definition: elements.hpp:51
scalar_type w
Argument of periapsis (omega), in radians.
Definition: elements.hpp:54
scalar_type in
Inclination (i), in radians.
Definition: elements.hpp:48