2
3
4
5
6
7
8
9
10
11
12
13
14
15
17#ifndef CALC_XDOT_GRAVITY_J2_J3_HPP
18#define CALC_XDOT_GRAVITY_J2_J3_HPP
20#include "utils/Rates.hpp"
23#define NUM_STATES_GRAV 6
24#define XDOT_PHIDOT_GRAVITY_J2_J3_STATES 42
62 T r = std::sqrt(state[0]*state[0] + state[1]*state[1] + state[2]*state[2]);
67 T z2 = state[2]*state[2];
70 T mu_over_r3, pc_15_2_r7, pc_3_2_r5, pc_35_2_r9;
71 int err = safeDivide(-
mu, r3, mu_over_r3);
if(err) {
return err;}
72 err = safeDivide(7.5*state[2], r7, pc_15_2_r7);
if(err) {
return err;}
73 err = safeDivide(1.5, r5, pc_3_2_r5);
if(err) {
return err;}
74 err = safeDivide(17.5*z2*state[2], r9, pc_35_2_r9);
if(err) {
return err;}
77 out_rates[0] = state[3];
78 out_rates[1] = state[4];
79 out_rates[2] = state[5];
81 out_rates[3] = mu_over_r3*state[0] +
82 pc_j2*(pc_15_2_r7*state[0]*state[2] - pc_3_2_r5*state[0]) +
83 pc_j3*(-pc_15_2_r7*state[0] + pc_35_2_r9*state[0]);
84 out_rates[4] = mu_over_r3*state[1] +
85 pc_j2*(pc_15_2_r7*state[1]*state[2] - pc_3_2_r5*state[1]) +
86 pc_j3*(-pc_15_2_r7*state[1] + pc_35_2_r9*state[1]);
87 out_rates[5] = mu_over_r3*state[2] +
88 pc_j2*(pc_15_2_r7*z2 - 3.0*pc_3_2_r5*state[2]) +
89 pc_j3*(-2.0*pc_15_2_r7*state[2] + pc_35_2_r9*state[2] + pc_3_2_r5);
92 _phi_tmp.setFromArray(&state[6]);
93 calcDfDzGravityJ2J3(state,
mu,
J2,
J3,
R, _A);
94 _phi_tmp = _A*_phi_tmp;
95 _phi_tmp.getAsArray(&out_rates[6]);
#define NUM_STATES_GRAV
Definition CalcXdotPhiDotGravityJ2J3.hpp:23
#define XDOT_PHIDOT_GRAVITY_J2_J3_STATES
Definition CalcXdotPhiDotGravityJ2J3.hpp:24
Definition CalcXdotPhiDotGravityJ2J3.hpp:29
T J2
The J2 parameter for the planet. Must be set prior to calculation.
Definition CalcXdotPhiDotGravityJ2J3.hpp:42
T R
The reference radius for the planet. Must be set prior to calculation.
Definition CalcXdotPhiDotGravityJ2J3.hpp:48
int calculateRates(T time, const std::array< T, 42 > &state, std::array< T, 42 > &out_rates)
Function to calculate rate of change in 6-element orbit position with J2, J3.
Definition CalcXdotPhiDotGravityJ2J3.hpp:56
T J3
The J3 parameter for the planet. Must be set prior to calculation.
Definition CalcXdotPhiDotGravityJ2J3.hpp:45
T mu
The gravitational parameter for the planet. Must be set prior to calculation.
Definition CalcXdotPhiDotGravityJ2J3.hpp:39
Matrix math implementation.
Definition Matrix.hpp:54
#define NO_ERROR
Definition clockwerkerrors.h:31