Spacecraft Control Framework 1.0
Spacecraft Control Library
Classes | Typedefs | Functions
sc_gravity.h File Reference

Spherical harmonic gravity model type and functions. More...

Go to the source code of this file.

Classes

struct  gravity_s
 Structure for storing gravitational properties of a planet, used to compute the gravitational matrix at a location and time. More...
 

Typedefs

typedef struct gravity_s gravity_t
 Structure for storing gravitational properties of a planet, used to compute the gravitational matrix at a location and time.
 

Functions

gravity_tinit_gravity (int z_harm, int t_harm, int spherical, double p_radius, double mu, const ml_matrix &c_dist, const ml_matrix &s_dist, const ml_matrix &j)
 Allocate and initialize a gravity structure. More...
 
void destroy_gravity (gravity_t *gravity)
 Deallocate a gravity structure. More...
 
ml_matrix compute_gravity (gravity_t *gravity, const ml_matrix &x_eci, const ml_matrix &m_eci_to_ef)
 Compute the gravity matrix at a location and time. More...
 
double total_energy_n_body (const ml_matrix &r, const ml_matrix &v, const ml_matrix &mass)
 Compute the total energy for n bodies. More...
 
ml_matrix gravity_n_body (const ml_matrix &r, const ml_matrix &mass, double eps=0)
 Compute the gravity for n bodies. More...
 
ml_matrix accel_planet (const ml_matrix &r, ml_matrix &mu, ml_matrix &rho)
 Compute the gravity for n bodies. More...
 
ml_matrix accel_planet (const ml_matrix &r, double mu, ml_matrix &rho)
 Compute the gravity for n bodies. More...
 

Detailed Description

Spherical harmonic gravity model type and functions.

Function Documentation

◆ init_gravity()

gravity_t * init_gravity ( int  z_harm,
int  t_harm,
int  spherical,
double  p_radius,
double  mu,
const ml_matrix &  c_coef,
const ml_matrix &  s_coef,
const ml_matrix &  j 
)

Allocate and initialize a gravity structure.

Allocate and initialize a gravity structure.

Parameters
z_harmNumber of zonal harmonics
t_harmNumber of tesseral harmonics
sphericalIf non-zero, include the spherical gravity term in the output force
p_radiusPlanet equatorial radius
muPlanet spherical gravity coefficient
s_coefThe sine term coefficients
c_coefThe cosine term coefficients
jThe J coefficients
Returns
A newly allocated gravity structure. This structure should be deallocated using destroy_gravity() when it is no longer needed.

References gravity_s::c_coef, gravity_s::c_dist, gravity_s::l_coef, gravity_s::mu, gravity_s::p_radius, gravity_s::s_coef, gravity_s::s_dist, gravity_s::spherical, gravity_s::t_harm, and gravity_s::z_harm.

◆ destroy_gravity()

void destroy_gravity ( gravity_t gravity)

Deallocate a gravity structure.

Deallocate a gravity structure.

Parameters
gravityThe gravity structure to be deallocated.

◆ compute_gravity()

ml_matrix compute_gravity ( gravity_t gravity,
const ml_matrix &  x_eci,
const ml_matrix &  m_eci_to_ef 
)

Compute the gravity matrix at a location and time.

Parameters
gravityThe gravity structure to use in the computation.
x_eciThe position matrix at which to calculate the gravity.
m_eci_to_efTransformation matrix from eci to earth fixed.
Returns
A 3x1 matrix representing the acceleration due to gravity at the specified location and time.

References gravity_s::c_dist, gravity_s::l_coef, gravity_s::mu, gravity_s::p_radius, gravity_s::s_dist, gravity_s::spherical, gravity_s::t_harm, and gravity_s::z_harm.

◆ total_energy_n_body()

double total_energy_n_body ( const ml_matrix &  r,
const ml_matrix &  v,
const ml_matrix &  mass 
)

Compute the total energy for n bodies.

Compute the total energy for n bodies.

Parameters
rPosition vectors [r1 r2 ... rn]
vVelocity vector [v1 v2 ... vn]
massPlanet mass [m1, m2, ... mn]
Returns
total energy

◆ gravity_n_body()

ml_matrix gravity_n_body ( const ml_matrix &  r,
const ml_matrix &  mass,
double  eps 
)

Compute the gravity for n bodies.

Compute the gravity for n bodies.

Parameters
rState vector [r1 r2 ... rn]
massPlanet mass [m1, m2, ... mn]
epsFactor to account for being too close to a gravity source
Returns
x dot

◆ accel_planet() [1/2]

ml_matrix accel_planet ( const ml_matrix &  r,
ml_matrix &  mu,
ml_matrix &  rho 
)

Compute the gravity for n bodies.

Compute the gravity for n bodies.

Parameters
rVector of the spacecraft from the central body
muPlanet gravitational parameter(s)
rhoVector of the perturbing planet(s) from the central body

Referenced by accel_planet(), and gravity_earth::compute_accel().

◆ accel_planet() [2/2]

ml_matrix accel_planet ( const ml_matrix &  r,
double  mu,
ml_matrix &  rho 
)

Compute the gravity for n bodies.

Compute the gravity for n bodies.

Parameters
rVector of the spacecraft from the central body
muPlanet gravitational parameter(s)
rhoVector of the perturbing planet(s) from the central body

References accel_planet().