Spacecraft Control Framework 1.0
Spacecraft Control Library
sc_orbit.h
Go to the documentation of this file.
1/*
2 * orbit.h
3 *
4 * Programmers: Joe Mueller, Mike Paluszek, Stephanie Thomas, Wil Turner, Lavanya Swetharanyan
5 *
6 * Copyright 1999-2006, Princeton Satellite Systems. All rights reserved.
7 *
8 * Orbit functions. Primarily orbit mechanics.
9 */
10
17#ifndef __SC_ORBIT__
18#define __SC_ORBIT__
19
20#ifdef AS_OS_WINDOWS
21#include "matrixlib.h"
22#else
23#include <MatrixLib/MatrixLib.h>
24#endif
25
26#include "sc_constants.h"
27
28extern "C++"
29{
30
33typedef struct orb_data_s {
34 double sma;
35 double inc;
36 double raan;
37 double perigee;
38 double ecc;
39 double mean_anom;
40 double true_anom;
41 double orb_rate;
42 double epoch;
44
47typedef struct gps_data_s {
48 double tc;
49 double a0;
50 double a1;
51 double a2;
52 double te;
53 double t0;
54 double ecc;
55 double sqrt_ax;
56 double m0;
57 double w0;
58 double i0;
59 double l0;
60 double delta_n;
61 double i_dot;
62 double omega_dot;
63 double cuc;
64 double cus;
65 double crc;
66 double crs;
67 double cic;
68 double cis;
69 double ta;
70 double w;
71 double delta_inc;
72 double dm_plane;
76
79typedef struct gps_orb_out_s {
80 ml_matrix r;
81 ml_matrix v;
82 ml_matrix delta;
84
85
89 ml_matrix r;
90 ml_matrix d;
91 ml_matrix julian_date;
92 ml_int_array id;
94
95
97void el_to_rv(const orb_data_t &data, ml_matrix &pos, ml_matrix &vel);
99void rv_to_nearest( const ml_matrix &pos, const ml_matrix &vel, const ml_matrix &pos_target, double jD, ml_matrix &distance, ml_matrix &time );
101orb_data_t rv_to_el(const ml_matrix &pos, const ml_matrix &vel, double mu=MU_EARTH);
103double r_to_true(double a, double e, double r);
105double rv_to_sma(double r_mag, double v_mag, double mu=MU_EARTH);
107double mean_to_true(double ecc, double mean);
109double mean_to_ecc(double ecc, double mean);
111double ecc_to_true(double ecc, double e );
113double ecc_to_mean(double ecc, double e );
115double true_to_mean(double ecc, double nu);
117double mean_to_true_abs(double ecc, double mean_anom);
119double true_to_ecc(double ecc, double nu);
121double rarp_to_ecc(double ap, double per);
123double rarp_to_sma(double ap, double per);
125double slr(double ecc, double sma);
127ml_matrix cp_to_i(double inc, double raan, double w);
129double orb_rate(double r, double a, double mu=MU_EARTH);
131double orb_rate(double r);
133double period(double a, double mu=MU_EARTH);
134
136void lin_orb(double n, ml_matrix &a, ml_matrix &b, double dt);
138void rv_orb_gen(const ml_matrix &el, const ml_matrix &t, ml_matrix &r, ml_matrix &v, double mu=MU_EARTH);
140void rv_orb_gen(const orb_data_t &el, const ml_matrix &t, ml_matrix &r, ml_matrix &v, double mu=MU_EARTH);
142ml_matrix cart_orb_rhs(const ml_matrix &x);
144ml_matrix cart_orb_rhs(const ml_matrix &x, const ml_matrix &a);
145
147ml_matrix satellite_visibility(const ml_matrix &from_pos, const ml_matrix &targets, double horizon_angle, double radius);
148
150ml_matrix planetary_accelerations(const ml_matrix &pos, double jd, int center);
151
153ml_matrix acc_planet(const ml_matrix &pos, double mu, const ml_matrix &rho);
154
156ml_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);
157
159double phase_change_dv(double a0, double deltaA, double kTarget, double mu );
160
162ml_matrix circular_maneuver( double p, double r, double m );
163
168ml_matrix gps_satellite( double jD );
169
171orbit_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 );
172
174ml_matrix r_ef_from_el( const orb_data_t &el, int n_points = 1000, int n_orbits = 1 );
175
177ml_matrix gps_eci_state_from_data( double longitude, double latitude, double heading, double velocity, double altitude, double jd );
178
180void print_orbit_data(orb_data_s orbData);
181}
182
183#endif
struct orbit_closest_point_out orbit_closest_point_out
Structure for storing the data output of the closest orbit.
struct orb_data_s orb_data_t
Structure for storing orbit data.
struct gps_orb_out_s gps_orb_out_t
Structure for storing the orbit data output of the GPS Model.
struct gps_data_s gps_data_t
Data structure for the GPS model.
Physical and mathematical constants.
const double MU_EARTH
Earth gravitational constant [km^3/sec^2].
Definition: sc_constants.h:53
ml_matrix circular_maneuver(double p, double r, double m)
Compute radial force and tangential impulse for a circular maneuver.
Definition: sc_orbit.cc:1024
ml_matrix satellite_visibility(const ml_matrix &from_pos, const ml_matrix &targets, double horizon_angle, double radius)
Compute satellite visibility.
Definition: sc_orbit.cc:883
ml_matrix r_ef_from_el(const orb_data_t &el, int n_points=1000, int n_orbits=1)
Closest r from elements.
Definition: sc_orbit.cc:1113
double true_to_mean(double ecc, double nu)
Converts true anomaly to mean anomaly.
Definition: sc_orbit.cc:527
double mean_to_ecc(double ecc, double mean)
Generate the eccentric anomaly from the mean anomaly and the eccentricity.
Definition: sc_orbit.cc:455
ml_matrix cp_to_i(double inc, double raan, double w)
Converts the transformation matrix from the perifocal frame to the inertial frame.
Definition: sc_orbit.cc:635
ml_matrix gps_satellite(double jD)
GPS satellite locations.
Definition: sc_orbit.cc:973
double slr(double ecc, double sma)
Compute the semi-latus rectum.
Definition: sc_orbit.cc:614
double r_to_true(double a, double e, double r)
Converts distance, sma and e to true anomaly.
Definition: sc_orbit.cc:391
double rarp_to_sma(double ap, double per)
Computes the semi major axis from apogee and perigee radii.
Definition: sc_orbit.cc:603
double period(double a, double mu=MU_EARTH)
Compute the orbital period.
Definition: sc_orbit.cc:691
double true_to_ecc(double ecc, double nu)
Converts true anomaly to eccentric or hyperbolic anomaly.
Definition: sc_orbit.cc:571
double ecc_to_mean(double ecc, double e)
Converts eccentric anomaly to mean anomaly.
Definition: sc_orbit.cc:507
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].
Definition: sc_orbit.cc:663
double mean_to_true(double ecc, double mean)
Computes the true anomaly from the mean anomaly.
Definition: sc_orbit.cc:416
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.
Definition: sc_orbit.cc:25
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.
double rv_to_sma(double r_mag, double v_mag, double mu=MU_EARTH)
Computes the semimajor axis given position and velocity.
Definition: sc_orbit.cc:405
double mean_to_true_abs(double ecc, double mean_anom)
Converts mean anomaly to true without wrapping.
Definition: sc_orbit.cc:548
double rarp_to_ecc(double ap, double per)
Compute the eccentricity from apogee and perigee radii.
Definition: sc_orbit.cc:591
ml_matrix gps_eci_state_from_data(double longitude, double latitude, double heading, double velocity, double altitude, double jd)
ECI state from GPS data.
Definition: sc_orbit.cc:1155
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.
Definition: sc_orbit.cc:941
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 coordina...
Definition: sc_orbit.cc:851
double phase_change_dv(double a0, double deltaA, double kTarget, double mu)
Compute delta-v for a phase change.
Definition: sc_orbit.cc:960
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.
Definition: sc_orbit.cc:120
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.
Definition: sc_orbit.cc:789
void print_orbit_data(orb_data_s orbData)
Display the contents of the passed-in orb_data_s struct.
Definition: sc_orbit.cc:1142
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.
Definition: sc_orbit.cc:251
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.
Definition: sc_orbit.cc:1044
double ecc_to_true(double ecc, double e)
Computes the true anomaly from the eccentric or hyperbolic anomaly.
Definition: sc_orbit.cc:489
ml_matrix planetary_accelerations(const ml_matrix &pos, double jd, int center)
Compute perturbations due to other planets aside from the center.
Definition: sc_orbit.cc:910
void lin_orb(double n, ml_matrix &a, ml_matrix &b, double dt)
Computes the linearized orbit equations.
Definition: sc_orbit.cc:715
Data structure for the GPS model.
Definition: sc_orbit.h:47
double cuc
Correction coefficient (argument of perigee).
Definition: sc_orbit.h:63
double l0
Longitude of the node at the weekly epoch [rad].
Definition: sc_orbit.h:59
double a1
Satellite clock drift.
Definition: sc_orbit.h:50
double t0
Sidereal time reference epoch.
Definition: sc_orbit.h:53
double sqrt_ax
Square root of semi-major axis.
Definition: sc_orbit.h:55
double i0
Inclination [rad].
Definition: sc_orbit.h:58
double cis
Correction coefficient (inclination).
Definition: sc_orbit.h:68
int satellite
GPS satellite index.
Definition: sc_orbit.h:73
double crc
Correction coefficient (radius).
Definition: sc_orbit.h:65
double dm_plane
Right ascension of the ascending node [rad].
Definition: sc_orbit.h:72
double a0
Satellite clock offset.
Definition: sc_orbit.h:49
double m0
Mean anomaly at reference epoch [rad].
Definition: sc_orbit.h:56
double delta_inc
Inclination delta (semicircles).
Definition: sc_orbit.h:71
double te
Ephemerides reference epoch.
Definition: sc_orbit.h:52
double ecc
Eccentricity.
Definition: sc_orbit.h:54
double w
Argument of perigee (semicircles).
Definition: sc_orbit.h:70
double tc
Satellite clock reference epoch.
Definition: sc_orbit.h:48
double delta_n
Mean motion difference.
Definition: sc_orbit.h:60
double cus
Correction coefficient (argument of perigee).
Definition: sc_orbit.h:64
double ta
Ephemerides reference epoch.
Definition: sc_orbit.h:69
bool broadcast_ephem
Whether or not the ephemerides are broadcast.
Definition: sc_orbit.h:74
double w0
Argument of perigee [rad].
Definition: sc_orbit.h:57
double omega_dot
Rate of note's right ascension.
Definition: sc_orbit.h:62
double a2
Satellite clock frequency drift.
Definition: sc_orbit.h:51
double cic
Correction coefficient (inclination).
Definition: sc_orbit.h:67
double crs
Correction coefficient (radius).
Definition: sc_orbit.h:66
double i_dot
Rate of inclination angle [rad/s].
Definition: sc_orbit.h:61
Structure for storing the orbit data output of the GPS Model.
Definition: sc_orbit.h:79
ml_matrix delta
Clock error.
Definition: sc_orbit.h:82
ml_matrix v
Velocity vector.
Definition: sc_orbit.h:81
ml_matrix r
Position vector.
Definition: sc_orbit.h:80
Structure for storing orbit data.
Definition: sc_orbit.h:33
double epoch
Epoch [Julian Days from J2000].
Definition: sc_orbit.h:42
double perigee
Argument of perigee [rad].
Definition: sc_orbit.h:37
double orb_rate
Mean orbit rate [rad/day].
Definition: sc_orbit.h:41
double sma
Semi-major axis [km].
Definition: sc_orbit.h:34
double mean_anom
Mean anomaly at epoch [rad].
Definition: sc_orbit.h:39
double ecc
Eccentricity.
Definition: sc_orbit.h:38
double raan
Right ascension of the ascending node [rad].
Definition: sc_orbit.h:36
double inc
Inclination [rad].
Definition: sc_orbit.h:35
double true_anom
True anomaly at epoch [rad].
Definition: sc_orbit.h:40
Structure for storing the data output of the closest orbit.
Definition: sc_orbit.h:88
ml_matrix d
minimum distance
Definition: sc_orbit.h:90
ml_matrix julian_date
Julian data.
Definition: sc_orbit.h:91
ml_int_array id
id
Definition: sc_orbit.h:92
ml_matrix r
Position vector.
Definition: sc_orbit.h:89