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"
22#define XDOT_GRAVITY_J2_J3_STATES 6
58 T r = std::sqrt(state[0]*state[0] + state[1]*state[1] + state[2]*state[2]);
63 T z2 = state[2]*state[2];
66 T mu_over_r3, pc_15_2_r7, pc_3_2_r5, pc_35_2_r9;
67 int err = clockwerk::safeDivide(-mu, r3, mu_over_r3);
if(err) {
return err;}
68 err = clockwerk::safeDivide(7.5*state[2], r7, pc_15_2_r7);
if(err) {
return err;}
69 err = clockwerk::safeDivide(1.5, r5, pc_3_2_r5);
if(err) {
return err;}
70 err = clockwerk::safeDivide(17.5*z2*state[2], r9, pc_35_2_r9);
if(err) {
return err;}
73 out_rates[0] = state[3];
74 out_rates[1] = state[4];
75 out_rates[2] = state[5];
77 out_rates[3] = mu_over_r3*state[0] +
78 pc_j2*(pc_15_2_r7*state[0]*state[2] - pc_3_2_r5*state[0]) +
79 pc_j3*(-pc_15_2_r7*state[0] + pc_35_2_r9*state[0]);
80 out_rates[4] = mu_over_r3*state[1] +
81 pc_j2*(pc_15_2_r7*state[1]*state[2] - pc_3_2_r5*state[1]) +
82 pc_j3*(-pc_15_2_r7*state[1] + pc_35_2_r9*state[1]);
83 out_rates[5] = mu_over_r3*state[2] +
84 pc_j2*(pc_15_2_r7*z2 - 3.0*pc_3_2_r5*state[2]) +
85 pc_j3*(-2.0*pc_15_2_r7*state[2] + pc_35_2_r9*state[2] + pc_3_2_r5);
#define XDOT_GRAVITY_J2_J3_STATES
Definition CalcXdotGravityJ2J3.hpp:22
Definition CalcXdotGravityJ2J3.hpp:27
T J2
The J2 parameter for the planet. Must be set prior to calculation.
Definition CalcXdotGravityJ2J3.hpp:40
int calculateRates(T time, const std::array< T, 6 > &state, std::array< T, 6 > &out_rates)
Function to calculate rate of change in 6-element orbit position with J2, J3.
Definition CalcXdotGravityJ2J3.hpp:52
T mu
The gravitational parameter for the planet. Must be set prior to calculation.
Definition CalcXdotGravityJ2J3.hpp:37
T R
The reference radius for the planet. Must be set prior to calculation.
Definition CalcXdotGravityJ2J3.hpp:46
T J3
The J3 parameter for the planet. Must be set prior to calculation.
Definition CalcXdotGravityJ2J3.hpp:43
#define NO_ERROR
Definition clockwerkerrors.h:31