Spacecraft Control Framework 1.0
Spacecraft Control Library
|
Orbit mechanics functions and types, including Keplerian, spherical and cartesian elements. More...
Go to the source code of this file.
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... | |
struct | orbit_closest_point_out |
Structure for storing the data output of the closest orbit. 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. | |
typedef struct orbit_closest_point_out | orbit_closest_point_out |
Structure for storing the data output of the closest orbit. | |
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. More... | |
void | rv_to_nearest (const ml_matrix &pos, const ml_matrix &vel, const ml_matrix &pos_target, double jD, ml_matrix &distance, ml_matrix &time) |
Compute nearest distance and time to a set of points on the earth. | |
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. More... | |
double | r_to_true (double a, double e, double r) |
Converts distance, sma and e to true anomaly. More... | |
double | rv_to_sma (double r_mag, double v_mag, double mu=MU_EARTH) |
Computes the semimajor axis given position and velocity. More... | |
double | mean_to_true (double ecc, double mean) |
Computes the true anomaly from the mean anomaly. More... | |
double | mean_to_ecc (double ecc, double mean) |
Generate the eccentric anomaly from the mean anomaly and the eccentricity. More... | |
double | ecc_to_true (double ecc, double e) |
Computes the true anomaly from the eccentric or hyperbolic anomaly. More... | |
double | ecc_to_mean (double ecc, double e) |
Converts eccentric anomaly to mean anomaly. More... | |
double | true_to_mean (double ecc, double nu) |
Converts true anomaly to mean anomaly. More... | |
double | mean_to_true_abs (double ecc, double mean_anom) |
Converts mean anomaly to true without wrapping. More... | |
double | true_to_ecc (double ecc, double nu) |
Converts true anomaly to eccentric or hyperbolic anomaly. More... | |
double | rarp_to_ecc (double ap, double per) |
Compute the eccentricity from apogee and perigee radii. More... | |
double | rarp_to_sma (double ap, double per) |
Computes the semi major axis from apogee and perigee radii. More... | |
double | slr (double ecc, double sma) |
Compute the semi-latus rectum. More... | |
ml_matrix | cp_to_i (double inc, double raan, double w) |
Converts the transformation matrix from the perifocal frame to the inertial frame. More... | |
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]. More... | |
double | orb_rate (double r) |
Compute the orbital rate for circular orbits and distance units in [km]. More... | |
double | period (double a, double mu=MU_EARTH) |
Compute the orbital period. More... | |
void | lin_orb (double n, ml_matrix &a, ml_matrix &b, double dt) |
Computes the linearized orbit equations. More... | |
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. More... | |
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. More... | |
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. More... | |
ml_matrix | cart_orb_rhs (const ml_matrix &x, const ml_matrix &a) |
Right hand side of the cartesion equations of motion. More... | |
ml_matrix | satellite_visibility (const ml_matrix &from_pos, const ml_matrix &targets, double horizon_angle, double radius) |
Compute satellite visibility. More... | |
ml_matrix | planetary_accelerations (const ml_matrix &pos, double jd, int center) |
Compute perturbations due to other planets aside from the center. More... | |
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. More... | |
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. More... | |
double | phase_change_dv (double a0, double deltaA, double kTarget, double mu) |
Compute delta-v for a phase change. More... | |
ml_matrix | circular_maneuver (double p, double r, double m) |
Compute radial force and tangential impulse for a circular maneuver. More... | |
ml_matrix | gps_satellite (double jD) |
GPS satellite locations. More... | |
orbit_closest_point_out | orbit_closest_point (const ml_matrix &r_ef_target, const ml_int_array &t_target, const orb_data_s &el, int n_points=1000, int n_orbits=1) |
Closest points in an orbit. More... | |
ml_matrix | r_ef_from_el (const orb_data_t &el, int n_points=1000, int n_orbits=1) |
Closest r from elements. | |
ml_matrix | gps_eci_state_from_data (double longitude, double latitude, double heading, double velocity, double altitude, double jd) |
ECI state from GPS data. | |
void | print_orbit_data (orb_data_s orbData) |
Display the contents of the passed-in orb_data_s struct. | |
Orbit mechanics functions and types, including Keplerian, spherical and cartesian elements.
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.
Converts orbital elements to r and v for an elliptic orbit.
data | Orbital elements for the satellite. |
pos | position "r" matrix to be returned (km). |
vel | velocity "v" matrix to be returned (km/s). |
References cp_to_i(), orb_data_s::ecc, orb_data_s::inc, orb_data_s::mean_anom, mean_to_true(), MU_EARTH, orb_data_s::perigee, orb_data_s::raan, and orb_data_s::sma.
Referenced by FFEccDeltaElem2Hills(), FFEccHills2DeltaElem(), ImpulsiveManeuver(), orbit_acquisition_dv(), r_ef_from_el(), and galilean_moons::update().
orb_data_t rv_to_el | ( | const ml_matrix & | pos, |
const ml_matrix & | vel, | ||
double | mu | ||
) |
Converts position and velocity vectors to Keplerian orbital elements.
pos | position "r" matrix for the satellite (km). |
vel | velocity "v" matrix for the satellite (km/s). |
mu | gravitational constant for the central body of the orbit pair (km^3/sec^2) |
References orb_data_s::ecc, orb_data_s::inc, orb_data_s::mean_anom, orb_data_s::orb_rate, orb_rate(), orb_data_s::perigee, PI, orb_data_s::raan, orb_data_s::sma, orb_data_s::true_anom, true_to_mean(), and TWO_PI.
Referenced by ECI2MeanElements(), FFEccHills2DeltaElem(), and GetHillsMats().
double r_to_true | ( | double | a, |
double | e, | ||
double | r | ||
) |
Converts distance, sma and e to true anomaly.
Converts distance, sma and e to true anomaly.
a | semimajor axis |
e | eccentricity |
r | distance |
double rv_to_sma | ( | double | r_mag, |
double | v_mag, | ||
double | mu | ||
) |
Computes the semimajor axis given position and velocity.
Computes the semimajor axis given position and velocity.
r_mag | Position magnitude (length). |
v_mag | Velocity magnitude (length/s). |
mu | Gravitational parameter (length^3/s^2). |
double mean_to_true | ( | double | ecc, |
double | mean_anom | ||
) |
Computes the true anomaly from the mean anomaly.
ecc | Eccentricity. |
mean_anom | Mean anomaly (rad). |
Referenced by AutoFormGeometry(), DeltaEl2AlfriendMat(), El2Alfriend(), el_to_rv(), FFEccDiscreteHills(), FFEccEstimateCost(), GenerateTimeVector(), GVEErrorDynamics(), ImpulsiveLPManeuver(), IterativeImpulsiveManeuver(), LPEccentricGVE(), LPEccentricTimeWeight(), mean_to_true_abs(), MeanAnom2TrueLat(), MonitoringAlg(), rv_orb_gen(), and TargetTrueAnom().
double mean_to_ecc | ( | double | ecc, |
double | mean_anom | ||
) |
Generate the eccentric anomaly from the mean anomaly and the eccentricity.
ecc | Eccentricity. |
mean_anom | Mean anomaly (rad). |
double ecc_to_true | ( | double | ecc, |
double | e | ||
) |
Computes the true anomaly from the eccentric or hyperbolic anomaly.
ecc | Eccentricity. |
e | Hyperbolic or Eccentric anomaly (rad). |
double ecc_to_mean | ( | double | ecc, |
double | e | ||
) |
Converts eccentric anomaly to mean anomaly.
ecc | Eccentricity. |
hyp | Hyperbolic anomaly (rad). |
Referenced by true_to_mean().
double true_to_mean | ( | double | ecc, |
double | nu | ||
) |
Converts true anomaly to mean anomaly.
ecc | Eccentricity. |
nu | True anomaly (rad). |
References ecc_to_mean(), and true_to_ecc().
Referenced by Alfriend2El(), FFEccDiscreteHills(), GenerateTimeVector(), LPEccentric(), LPEccentricGVE(), rv_to_el(), TargetTrueAnom(), and TimeUntilTheta().
double mean_to_true_abs | ( | double | ecc, |
double | mean_anom | ||
) |
Converts mean anomaly to true without wrapping.
Converts mean anomaly to true without wrapping.
ecc | Eccentricity in radians. |
mean_anom | Mean anomaly in radians. |
References mean_to_true(), PI, and TWO_PI.
double true_to_ecc | ( | double | ecc, |
double | nu | ||
) |
Converts true anomaly to eccentric or hyperbolic anomaly.
ecc | Eccentricity in radians. |
nu | True anomaly in radians. |
Referenced by true_to_mean().
double rarp_to_ecc | ( | double | ap, |
double | per | ||
) |
Compute the eccentricity from apogee and perigee radii.
ap | Apogee radius. |
per | Perigee radius. |
double rarp_to_sma | ( | double | ap, |
double | per | ||
) |
Computes the semi major axis from apogee and perigee radii.
Computes the semi major axis from apogee and perigee radii.
ap | Apogee radius. |
per | Perigee radius. |
double slr | ( | double | ecc, |
double | sma | ||
) |
Compute the semi-latus rectum.
ecc | Eccentricity. |
sma | Semi major axis (or perigee radius for parabola). |
Referenced by ImpulsiveManeuver(), and rv_orb_gen().
ml_matrix cp_to_i | ( | double | inc, |
double | raan, | ||
double | w | ||
) |
Converts the transformation matrix from the perifocal frame to the inertial frame.
inc | Inclination (rad). |
raan | Right ascension of the ascending node (rad). |
w | Argument of perigee (rad). |
Referenced by el_to_rv(), gps_satellite(), and rv_orb_gen().
double orb_rate | ( | double | r, |
double | sma, | ||
double | mu | ||
) |
Compute the orbital rate for non-circular orbits, or distance units other than [km].
r | Radius |
sma | Semi major axis (inf for parabola) |
mu | Gravitational parameter |
Referenced by FFEccDeltaElem2Goals(), FFEccEstimateCost(), FFEccGenerateTeamGoals(), GenerateTimeVector(), Goals2Hills(), ImpulsiveLPManeuver(), ImpulsiveManeuver(), IterativeImpulsiveManeuver(), LPCircularTimeWeight(), LPEccentricGVE(), LPEccentricTimeWeight(), MonitoringAlg(), rv_to_el(), and TimeUntilTheta().
double orb_rate | ( | double | r | ) |
Compute the orbital rate for circular orbits and distance units in [km].
r | Radius |
References MU_EARTH.
double period | ( | double | a, |
double | mu | ||
) |
Compute the orbital period.
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.
a | Semi-major axis |
mu | Gravitation parameter, default is Earth |
References TWO_PI.
Referenced by GenerateTeamGoals(), orbit_closest_point(), and r_ef_from_el().
void lin_orb | ( | double | n, |
ml_matrix & | a, | ||
ml_matrix & | b, | ||
double | dt | ||
) |
Computes the linearized orbit equations.
If value of dT is not equal to -1 it will generate the discrete time equations.
n | (1) orbit rate (rad/s). |
a | (6,6) State transition matrix. |
b | (6,3) Input matrix. |
dt | (1) Time step (s). |
Referenced by DiscreteHills(), and LPCircular().
void rv_orb_gen | ( | const ml_matrix & | el, |
const ml_matrix & | t, | ||
ml_matrix & | pos, | ||
ml_matrix & | vel, | ||
double | mu | ||
) |
Generate an orbit by propagating Keplerian elements.
el | (6,1) Elements vector [a,i,W,w,e,M] |
t | (1,n) Times from 0 to infinity (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, rv_orb_gen(), and orb_data_s::sma.
Referenced by orbit_acquisition_dv(), orbit_closest_point(), rv_orb_gen(), and Target().
void rv_orb_gen | ( | const orb_data_t & | el, |
const ml_matrix & | t, | ||
ml_matrix & | pos, | ||
ml_matrix & | vel, | ||
double | mu | ||
) |
Generate an orbit by propagating Keplerian elements.
Overloaded for calling with elements of type "orb_data_s"
el | (1,1) Elements data structure |
t | (1,n) Times from 0 to infinity (sec) |
pos | (3,n) Position vectors for times t |
vel | (3,n) Velocity vectors for times t |
mu | (1,1) Gravitational potential |
References cp_to_i(), orb_data_s::ecc, orb_data_s::inc, orb_data_s::mean_anom, mean_to_true(), orb_data_s::perigee, orb_data_s::raan, slr(), and orb_data_s::sma.
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.
x | (6,1) State [x;y;z;dx/dt;dy/dt;dz/dt], pos: (km), vel: (km/s) |
References MU_EARTH.
ml_matrix cart_orb_rhs | ( | const ml_matrix & | x, |
const ml_matrix & | a | ||
) |
Right hand side of the cartesion equations of motion.
x | (6,1) Current state vector, pos: (km), vel: (km/s). |
a | (3,1) Acceleration vector (km/s/s). |
References MU_EARTH.
ml_matrix satellite_visibility | ( | const ml_matrix & | from_pos, |
const ml_matrix & | targets, | ||
double | horizon_angle, | ||
double | radius | ||
) |
Compute satellite visibility.
from_pos | Position of the viewing satellite. |
targets | Positions of possibly visible satellites. |
horizon_angle | Angle above horizon for visibility |
radius | Planet radius. |
ml_matrix planetary_accelerations | ( | const ml_matrix & | pos, |
double | jd, | ||
int | center | ||
) |
Compute perturbations due to other planets aside from the center.
Currently only handles the earth, moon and sun.
pos | (3,1) Position vector wrt center |
jd | (1,1) Julian Date |
center | 1 for Earth and 2 for Moon |
References acc_planet(), moon_vector(), MU_EARTH, MU_MOON, MU_SUN, and sun_vector().
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.
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 |
Referenced by planetary_accelerations().
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.
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:
t | delta-V time (output) |
elI | Initial orbital elements |
elF | Final orbital elements |
smaTol | Tolerance on semi-major axis |
incTol | Tolerance on inclination |
raTol | Tolerance on right ascension |
References au_to_q(), el_to_rv(), orb_data_s::inc, orb_data_s::mean_anom, orb_data_s::perigee, PI, orb_data_s::raan, rv_orb_gen(), orb_data_s::sma, and WrapPhase().
double phase_change_dv | ( | double | a0, |
double | deltaA, | ||
double | kTarget, | ||
double | mu | ||
) |
Compute delta-v for a phase change.
Compute delta-v for a phase change.
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 |
References PI.
ml_matrix circular_maneuver | ( | double | p, |
double | r, | ||
double | m | ||
) |
Compute radial force and tangential impulse for a circular maneuver.
Compute radial force and tangential impulse for a circular maneuver.
p | Period (min) |
r | Radius of orbit (m) |
m | Mass (kg) |
References PI.
ml_matrix gps_satellite | ( | double | jD | ) |
GPS satellite locations.
Models the GPS constellation very approximately using a static set of elements. Each column is the stacked [r;v] of one GPS satellite.
jD | Julian date |
References cp_to_i().
orbit_closest_point_out orbit_closest_point | ( | const ml_matrix & | r_ef_target, |
const ml_int_array & | t_target, | ||
const orb_data_t & | el, | ||
int | n_points, | ||
int | n_orbits | ||
) |
Closest points in an orbit.
r_ef_target | Target positions in the earth fixed frame |
el | Orbit of observing spacecraft |
n_points | Number of points in the orbit to check |
n_orbits | Number of orbits to check |
References orb_data_s::epoch, orbit_closest_point_out::id, jd_to_jcent(), orbit_closest_point_out::julian_date, period(), orbit_closest_point_out::r, rv_orb_gen(), orb_data_s::sma, and true_earth().