Classes | Typedefs | Functions

sc_orbit.h File Reference

Orbit mechanics, including Keplerian, spherical and cartesian elements. More...

Classes

struct  orb_data_s
 Structure for storing orbit data. More...
struct  gps_data_s
 Data structure for the GPS model. More...
struct  gps_orb_out_s
 Structure for storing the orbit data output of the GPS Model. More...

Typedefs

typedef struct orb_data_s orb_data_t
 Structure for storing orbit data.
typedef struct gps_data_s gps_data_t
 Data structure for the GPS model.
typedef struct gps_orb_out_s gps_orb_out_t
 Structure for storing the orbit data output of the GPS Model.

Functions

void el_to_rv (const orb_data_t &data, ml_matrix &pos, ml_matrix &vel)
 Converts orbital elements to r and v for an elliptic orbit.
orb_data_t rv_to_el (const ml_matrix &pos, const ml_matrix &vel, double mu=MU_EARTH)
 Converts position and velocity vectors to Keplerian orbital elements.
double rv_to_sma (double r_mag, double v_mag, double mu=MU_EARTH)
 Computes the semimajor axis given position and velocity.
double mean_to_true (double ecc, double mean)
 Computes the true anomaly from the mean anomaly.
double mean_to_ecc (double ecc, double mean)
 Generate the eccentric anomaly from the mean anomaly and the eccentricity.
double ecc_to_true (double ecc, double hyp)
 Computes the true anomaly from the eccentric or hyperbolic anomaly.
double ecc_to_mean (double ecc, double hyp)
 Converts eccentric anomaly to mean anomaly.
double true_to_mean (double ecc, double nu)
 Converts true anomaly to mean anomaly.
double mean_to_true_abs (double ecc, double mean_anom)
 Converts mean anomaly to true without wrapping.
double true_to_ecc (double ecc, double nu)
 Converts true anomaly to eccentric or hyperbolic anomaly.
double rarp_to_ecc (double ap, double per)
 Compute the eccentricity from apogee and perigee radii.
double rarp_to_sma (double ap, double per)
 Computes the semi major axis from apogee and perigee radii.
double slr (double ecc, double sma)
 Compute the semi-latus rectum.
ml_matrix cp_to_i (double inc, double raan, double w)
 Converts the transformation matrix from the perifocal frame to the inertial frame.
double orb_rate (double r, double a, double mu=MU_EARTH)
 Compute the orbital rate for non-circular orbits, or distance units other than [km].
double orb_rate (double r)
 Compute the orbital rate for circular orbits and distance units in [km].
double period (double a, double mu=MU_EARTH)
 Compute the orbital period.
void lin_orb (double n, ml_matrix &a, ml_matrix &b, double dt)
 Computes the linearized orbit equations.
void rv_orb_gen (const ml_matrix &el, const ml_matrix &t, ml_matrix &r, ml_matrix &v, double mu=MU_EARTH)
 Generate an orbit by propagating Keplerian elements.
void rv_orb_gen (const orb_data_t &el, const ml_matrix &t, ml_matrix &r, ml_matrix &v, double mu=MU_EARTH)
 Generate an orbit by propagating Keplerian elements.
ml_matrix cart_orb_rhs (const ml_matrix &x)
 Computes the right-hand-side of the unforced orbit equations about a mass point in cartesian coordinates.
ml_matrix cart_orb_rhs (const ml_matrix &x, const ml_matrix &a)
 Right hand side of the cartesion equations of motion.
ml_matrix satellite_visibility (const ml_matrix &from_pos, const ml_matrix &targets, double horizon_angle, double radius)
 Compute satellite visibility.
ml_matrix planetary_accelerations (const ml_matrix &pos, double jd, int center)
 Compute perturbations due to other planets aside from the center.
ml_matrix acc_planet (const ml_matrix &pos, double mu, const ml_matrix &rho)
 Acceleration due to a planet on a spacecraft within the sphere of influence of another body.
ml_matrix orbit_acquisition_dv (ml_matrix &t, const orb_data_t &elI, const orb_data_t &elF, double smaTol=0.5, double incTol=1e-3, double raTol=1e-3)
 Compute delta-v sequence to acquire orbit.
double phase_change_dv (double a0, double deltaA, double kTarget, double mu)
 Compute delta-v for a phase change.
ml_matrix gps_satellite (double jD)
 GPS Satellite.

Detailed Description


Function Documentation

void el_to_rv ( const orb_data_t data,
ml_matrix &  pos,
ml_matrix &  vel 
)

Converts orbital elements to r and v for an elliptic orbit.

Parameters:
dataOrbital elements for the satellite.
posposition "r" matrix to be returned (km).
velvelocity "v" matrix to be returned (km/s).

References orb_data_s::ecc, orb_data_s::inc, orb_data_s::mean_anom, MU_EARTH, orb_data_s::perigee, orb_data_s::raan, and orb_data_s::sma.

orb_data_t rv_to_el ( const ml_matrix &  pos,
const ml_matrix &  vel,
double  mu 
)
Parameters:
posposition "r" matrix for the satellite (km).
velvelocity "v" matrix for the satellite (km/s).
mugravitational constant for the central body of the orbit pair (km^3/sec^2)
Returns:
The Keplerian orbital elements for the satellite.

References orb_data_s::ecc, orb_data_s::inc, orb_data_s::mean_anom, orb_data_s::orb_rate, orb_data_s::perigee, PI, orb_data_s::raan, orb_data_s::sma, orb_data_s::true_anom, and TWO_PI.

double rv_to_sma ( double  r_mag,
double  v_mag,
double  mu 
)

Computes the semimajor axis given position and velocity.

Parameters:
r_magPosition magnitude (length).
v_magVelocity magnitude (length/s).
muGravitational parameter (length^3/s^2).
Returns:
Semimajor axis (length).
double mean_to_true ( double  ecc,
double  mean_anom 
)
Parameters:
eccEccentricity.
mean_anomMean anomaly (rad).
Returns:
True anomaly (rad).
double mean_to_ecc ( double  ecc,
double  mean_anom 
)
Parameters:
eccEccentricity.
mean_anomMean anomaly (rad).
Returns:
Eccentric anomaly (rad).
double ecc_to_true ( double  ecc,
double  hyp 
)
Parameters:
eccEccentricity.
hypHyperbolic anomaly (rad0.
Returns:
True anomaly (rad).
double ecc_to_mean ( double  ecc,
double  hyp 
)
Parameters:
eccEccentricity.
hypHyperbolic anomaly (rad).
Returns:
Mean anomaly (rad).
double true_to_mean ( double  ecc,
double  nu 
)
Parameters:
eccEccentricity.
nuTrue anomaly (rad).
Returns:
Mean anomaly (rad).
double mean_to_true_abs ( double  ecc,
double  mean_anom 
)

Converts mean anomaly to true without wrapping.

Parameters:
eccEccentricity in radians.
mean_anomMean anomaly in radians.
Returns:
The true anomaly in radians.

References PI, and TWO_PI.

double true_to_ecc ( double  ecc,
double  nu 
)
Parameters:
eccEccentricity in radians.
nuTrue anomaly in radians.
Returns:
The eccentric or hyperbolic anomaly in radians.
double rarp_to_ecc ( double  ap,
double  per 
)
Parameters:
apApogee radius.
perPerigee radius.
Returns:
Eccentricity.
double rarp_to_sma ( double  ap,
double  per 
)

Computes the semi major axis from apogee and perigee radii.

Parameters:
apApogee radius.
perPerigee radius.
Returns:
The semi-major axis.
double slr ( double  ecc,
double  sma 
)
Parameters:
eccEccentricity.
smaSemi major axis (or perigee radius for parabola).
Returns:
Semi-latus rectum.
ml_matrix cp_to_i ( double  inc,
double  raan,
double  w 
)
Parameters:
incInclination (rad).
raanRight ascension of the ascending node (rad).
wArgument of perigee (rad).
Returns:
The inertial frame (3,3) transformation matrix.
double orb_rate ( double  r,
double  sma,
double  mu 
)
Parameters:
rRadius
smaSemi major axis (inf for parabola)
muGravitational parameter
Returns:
w Angular velocity
double orb_rate ( double  r )
Parameters:
rRadius
Returns:
w Angular velocity (rad/s)

References MU_EARTH.

double period ( double  a,
double  mu 
)

Compute the orbital period.

The units for a and mu must be consistent, for example [km] and [km3/s2]. FLT_MAX is substituted for infinity.

Parameters:
aSemi-major axis
muGravitation parameter, default is Earth
Returns:
p Orbital period (s)

References TWO_PI.

void lin_orb ( double  n,
ml_matrix &  a,
ml_matrix &  b,
double  dt 
)

If value of dT is not equal to -1 it will generate the discrete time equations.

Parameters:
n(1) orbit rate (rad/s).
a(6,6) State transition matrix.
b(6,3) Input matrix.
dt(1) Time step (s).
void rv_orb_gen ( const ml_matrix &  el,
const ml_matrix &  t,
ml_matrix &  pos,
ml_matrix &  vel,
double  mu 
)
Parameters:
el(6,1) Elements vector [a,i,W,w,e,M]
t(1,n) Times from 0 to ° (sec)
pos(3,n) Position vectors for times t
vel(3,n) Velocity vectors for times t
mu(1,1) Gravitational potential

References orb_data_s::ecc, orb_data_s::inc, orb_data_s::mean_anom, orb_data_s::perigee, orb_data_s::raan, and orb_data_s::sma.

void rv_orb_gen ( const orb_data_t el,
const ml_matrix &  t,
ml_matrix &  pos,
ml_matrix &  vel,
double  mu 
)

Overloaded for calling with elements of type "orb_data_s"

Parameters:
el(6,1) Elements vector [a,i,W,w,e,M]
t(1,n) Times from 0 to ° (sec)
pos(3,n) Position vectors for times t
vel(3,n) Velocity vectors for times t
mu(1,1) Gravitational potential

References orb_data_s::ecc, orb_data_s::inc, orb_data_s::mean_anom, orb_data_s::perigee, orb_data_s::raan, and orb_data_s::sma.

ml_matrix cart_orb_rhs ( const ml_matrix &  x )
Parameters:
x(6,1) State [x;y;z;dx/dt;dy/dt;dz/dt], pos: (km), vel: (km/s)
Returns:
xDot (6,1) State derivative

References MU_EARTH.

ml_matrix cart_orb_rhs ( const ml_matrix &  x,
const ml_matrix &  a 
)
Parameters:
x(6,1) Current state vector, pos: (km), vel: (km/s).
a(3,1) Acceleration vector (km/s/s).
Returns:
xDot (6,1) State derivative.

References MU_EARTH.

ml_matrix satellite_visibility ( const ml_matrix &  from_pos,
const ml_matrix &  targets,
double  horizon_angle,
double  radius 
)
Parameters:
from_posPosition of the viewing satellite.
targetsPositions of possibly visible satellites.
horizon_angleAngle above horizon for visibility
radiusPlanet radius.
Returns:
A ml_int_array with "1" for each visible satellite and "0" for each that is not visible.
ml_matrix planetary_accelerations ( const ml_matrix &  pos,
double  jd,
int  center 
)

Currently only handles the earth, moon and sun.

Parameters:
pos(3,1) Position vector wrt center
jd(1,1) Julian Date
center1 for Earth and 2 for Moon
Returns:
(3,1) Acceleration

References MU_EARTH, MU_MOON, and MU_SUN.

ml_matrix acc_planet ( const ml_matrix &  pos,
double  mu,
const ml_matrix &  rho 
)
Parameters:
pos(3,1) Vector of the spacecraft from the central body
mu(1) Planet's gravitational parameter
rho(3,:) Vector of the planet from the central body
Returns:
(3,1) Acceleration
ml_matrix orbit_acquisition_dv ( ml_matrix &  t,
const orb_data_t elI,
const orb_data_t elF,
double  smaTol,
double  incTol,
double  raTol 
)

Compute delta-v sequence to acquire orbit.

Inclination and right ascension correction are a single burn. Semi-major axis correction is a two-burn Hohmann transfer set. The conditions for performing a SMA correction are: 1. The SMA error exceeds the tolerance, AND 2. a) The final SMA is smaller than the initial, OR b) Both the inc. and r.a. error are within tolerance. The times will include the wait time for the necessary Hohmann phasing.

Parameters:
tdelta-V time (output)
elIInitial orbital elements
elFFinal orbital elements
smaTolTolerance on semi-major axis
incTolTolerance on inclination
raTolTolerance on right ascension
Returns:
Matrix of delta-V's (3xn)

References orb_data_s::inc, orb_data_s::mean_anom, orb_data_s::perigee, PI, orb_data_s::raan, and orb_data_s::sma.

double phase_change_dv ( double  a0,
double  deltaA,
double  kTarget,
double  mu 
)

Compute delta-v for a phase change.

Parameters:
a0(1,1) Initial semi-major axis
deltaA(1,1) Phase change
kTarget(1,1) Number of revolutions
mu(1,1) Planet's gravitational parameter
Returns:
(1,1) Delta-v

References PI.