Spacecraft Control Framework 1.0
Spacecraft Control Library
sc_ephemeris.h File Reference

Time and data conversions and planetary movement, position, and eclipse computations. More...

Go to the source code of this file.

Functions

Time/Date functions
double date_to_jd (const ml_matrix &dateTime)
 Converts date to jd. More...
 
double jd_to_utc_secs (double jd)
 Converts Julian date to seconds since 00:00:00 January 1, 1970 (UTC) More...
 
double utc_secs_to_jd (double secs)
 Converts seconds since 00:00:00 January 1, 1970 (UTC) to Julian date. More...
 
double jd_to_jcent (double jd)
 Convert Julian date to Julian century. More...
 
double jcent_to_jd (double jcent)
 Convert Julian century to Julian date. More...
 
double jd_to_midnight (double jd)
 Round a Julian date value to the most recent midnight (0 hours) value. More...
 
double gms_time (double jd)
 Get Greenwich Mean Sidereal time. More...
 
double ms_day (double jd)
 Compute a mean sidereal (solar) day. More...
 
double local_sidereal_time (double jd, double lon)
 Compute the local sidereal time for a given Julian date and longitude. More...
 
double mean_sidereal_day (double jd)
 Mean sidereal day

 
ml_matrix jd_to_date (double jd)
 Convert Julian date to date. More...
 
double jd_to_day_number (double jd)
 Convert Julian date to day number
More...
 
Star functions
ml_matrix stellar_reduction (const ml_matrix &rA0, const ml_matrix &dec0, const ml_matrix &pMRA, const ml_matrix &pMDec, const ml_matrix &parallax, const ml_matrix &rV, const ml_matrix &vSc, double jD)
 Stellar reduction. More...
 
void earth_barycenter (const ml_matrix &jD, ml_matrix eB, ml_matrix eB_dot)
 Earth barycenter. More...
 
void earth_barycenter (double jD, ml_matrix eB, ml_matrix eB_dot)
 
ml_matrix light_deflection (const ml_matrix &p, const ml_matrix &e)
 Light deflection. More...
 
ml_matrix stellar_aberration (const ml_matrix &u, const ml_matrix &v)
 Stellar aberration. More...
 
Planetary functions
ml_matrix meci_to_planet (double alpha0, double delta0, double w)
 Generate the ECI to Planet transformation matrix. More...
 
ml_matrix meci_to_earth (double jD)
 Generate the ECI to eart transformation matrix. More...
 
ml_matrix sun_vector (double jd, double &r)
 Generate the sun vector in the earth-centered inertial frame. More...
 
ml_matrix sun_vector (double jd)
 
ml_matrix moon_vector (double jd, double &r)
 Generate the moon vector in the earth-centered inertial frame. More...
 
ml_matrix true_earth (double jcent)
 Computes the matrix from mean of Aries 2000 to earth fixed frame. More...
 
ml_matrix earth_pre (double jcent)
 Computes the earth precession matrix. More...
 
ml_matrix earth_rot (double jcent)
 Computes the earth Greenwich matrix using GMST, that transforms from ECI to Earth-fixed. More...
 
ml_matrix earth_rot_eq (double jcent)
 Computes the earth Greenwich matrix using apparent sidereal time. More...
 
ml_matrix earth_nut (double jcent)
 The matrix that rotates from the mean axes to the true axes. More...
 
double nut_delta (double j_cent, double &delta_eps)
 The changes in longitude and obliquity due to earth nutation. More...
 
double ob_of_ecliptic (double jcent)
 Computes the mean obliquity of the ecliptic of date. More...
 
ml_matrix c_ecl_to_eq (double jD)
 Transformation from eclipic to equatorial. More...
 
double eq_of_equinoxes (double jcent)
 Computes the equation of the equinoxes. More...
 
double eclipse_spice (const ml_matrix &pos, const ml_matrix &planet_radius, const ml_matrix &planet_position, const ml_matrix &planet_index, int observer)
 Compute eclipses using Spice data. More...
 
double eclipse (const ml_matrix &pos, const ml_matrix &l_pos, const ml_matrix &p_pos, double p_radius=RADIUS_EARTH, double l_radius=RADIUS_SUN)
 Compute eclipses. More...
 
double earth_rate (double jd)
 Earth rotation rate.
 
ml_matrix local_star_position (double jd, double lY)
 Local star positions. More...
 
ml_matrix planet_ecliptic_to_orbit (int naif_code, double jd=JD_2000)
 Planet orbit rotation frame. More...
 
ml_matrix planet_ecliptic_to_orbit (char *planet_name, double jd=JD_2000)
 Generates planet rotation frame. More...
 

Detailed Description

Time and data conversions and planetary movement, position, and eclipse computations.

Function Documentation

◆ date_to_jd()

double date_to_jd ( const ml_matrix &  d)

Converts date to jd.

Converts date to jd.

The date vector is in the form [year month day hours minutes seconds] where all values should be integers except seconds which may be a double. If any columns of datetime are omitted they will be set to zero, as appropriate, with a default date of Jan 1, 2000 at 00:00.

Examples: jD = date_to_jd([2009]); // assumes January 1 at 0:00 jD = date_to_jd([2009 4 11]); jD = date_to_jd([2009 4 11 13 45]); jD = date_to_jd([2009 4 11 13 45 15.146]);

Parameters
dDate vector (1x6) to be converted to Julian date.
Returns
Returns the Julian date equivalent of the given calendar date.

Referenced by jd_to_day_number().

◆ jd_to_utc_secs()

double jd_to_utc_secs ( double  jd)

Converts Julian date to seconds since 00:00:00 January 1, 1970 (UTC)

Converts Julian date to seconds since 00:00:00 January 1, 1970 (UTC)

Parameters
jdJulian date value to be converted to UTC seconds.
Returns
Returns the UTC seconds value for a given Julian date.

References DAYS_TO_SECS, and JD_EPOCH.

◆ utc_secs_to_jd()

double utc_secs_to_jd ( double  secs)

Converts seconds since 00:00:00 January 1, 1970 (UTC) to Julian date.

Parameters
secsUTC seconds value to be converted to Julian date.
Returns
Returns the Julian date equivalent of the given UTC value.

References JD_EPOCH, and SECS_TO_DAYS.

◆ jd_to_jcent()

double jd_to_jcent ( double  jd)

Convert Julian date to Julian century.

Convert Julian date to Julian century.

Parameters
jdJulian date to be converted to Julian centuries.
Returns
Returns the Julian century equivalent of the given Julian date.

References DAYS_TO_CENTURIES, and JD_2000.

Referenced by b_dipole(), gravity_earth::compute_accel(), gms_time(), gps_eci_state_from_data(), mag_field(), meci_to_earth(), moon_vector(), ms_day(), orbit_closest_point(), r_ef_from_el(), and stellar_reduction().

◆ jcent_to_jd()

double jcent_to_jd ( double  jcent)

Convert Julian century to Julian date.

Convert Julian century to Julian date.

Parameters
jcentThe Julian century value to be converted to Julian date.
Returns
Returns the Julian date equivalent of the given Julian century.

References CENTURIES_TO_DAYS, and JD_2000.

Referenced by earth_rot(), and earth_rot_eq().

◆ jd_to_midnight()

double jd_to_midnight ( double  jd)

Round a Julian date value to the most recent midnight (0 hours) value.

Parameters
jdThe Julian date value to be rounded.
Returns
Returns the most recent midnight Julian date.

Referenced by gms_time(), and ms_day().

◆ gms_time()

double gms_time ( double  jd)

Get Greenwich Mean Sidereal time.

Get Greenwich Mean Sidereal time.

Gives the angle between the Greenwich Meridian and the Vernal Equinox (the x-axis in the ECI frame). This does not account for Earth nutation. Ref: The 1993 Astronomical Almanac, U.S. Government Printing Office, p. B6.

Parameters
jdJulian date at which to calculate the Greenwich Mean Sidereal time.
Returns
Returns the Greenwich Mean Sidereal time in degrees

References jd_to_jcent(), jd_to_midnight(), ms_day(), and SECS_TO_DAYS.

Referenced by earth_rot(), earth_rot_eq(), and local_sidereal_time().

◆ ms_day()

double ms_day ( double  jd)

Compute a mean sidereal (solar) day.

Compute a mean sidereal (solar) day.

Ref: The 1993 Astronomical Almanac, U.S. Government Printing Office, p. B6.

Parameters
jdJulian date value for which the mean sidereal day should be computed.
Returns
Returns the mean sidereal day at the given Julian date.

References DAYS_TO_SECS, jd_to_jcent(), and jd_to_midnight().

Referenced by gms_time().

◆ local_sidereal_time()

double local_sidereal_time ( double  jd,
double  lon 
)

Compute the local sidereal time for a given Julian date and longitude.

Parameters
jdJulian date
lonlongitude
Returns
local sidereal time

References gms_time().

◆ jd_to_date()

ml_matrix jd_to_date ( double  jd)

Convert Julian date to date.

Convert Julian date to date.

Parameters
jdThe Julian date value to be rounded.
Returns
[year month day minutes hours seconds]

References fix(), and r2p5().

Referenced by jd_to_day_number().

◆ jd_to_day_number()

double jd_to_day_number ( double  jd)

Convert Julian date to day number

Convert Julian date to day number

Parameters
jdThe Julian date value to be rounded.
Returns
Day number

References date_to_jd(), and jd_to_date().

Referenced by AtmJ70::Update().

◆ stellar_reduction()

ml_matrix stellar_reduction ( const ml_matrix &  rA0,
const ml_matrix &  dec0,
const ml_matrix &  pMRA,
const ml_matrix &  pMDec,
const ml_matrix &  parallax,
const ml_matrix &  rV,
const ml_matrix &  vSc,
double  jD 
)

Stellar reduction.

Stellar reduction.

Includes corrections for

  • radial velocity of star
  • parallax
  • gravitational light deflection
  • relativistic aberration due to earth and spacecraft velocity
  • Earth precession and nutation

Astronomical Almanac for 1993, B39-B41

Parameters
rA0Catalog right ascension
dec0Catalog declination
pMRAProper motion in right ascension
pMDecProper motion in declination
parallaxStellar parallax
rVRadial velocity (km/sec)
vScSpacecraft velocity vector (km/sec)
jDJulian date
Returns
Unit vector

References earth_barycenter(), jd_to_jcent(), light_deflection(), ra_dec_to_u(), and stellar_aberration().

◆ earth_barycenter()

void earth_barycenter ( const ml_matrix &  jD,
ml_matrix  eB,
ml_matrix  eB_dot 
)

Earth barycenter.

Earth barycenter.

Parameters
jD(1,:) Julian date
Returns
eB (3,:) Barycentric position (aU)
eBDot (3,:) Barycentric rate (aU/y)

References DEGREES_TO_RADIANS.

Referenced by stellar_reduction().

◆ light_deflection()

ml_matrix light_deflection ( const ml_matrix &  p,
const ml_matrix &  e 
)

Light deflection.

Light deflection.

Parameters
p(3,:) Vector from observing body to observed body
e(3,:) Vector from sun
Returns
p1 (3,:) Corrected p

Siedelmann, P., (1992). Explanatory Supplement to the Astronomical Almanac, University Science Books, Mill Valley, CA, 136-137.

Referenced by stellar_reduction().

◆ stellar_aberration()

ml_matrix stellar_aberration ( const ml_matrix &  u,
const ml_matrix &  v 
)

Stellar aberration.

Stellar aberration.

Parameters
u(3,1) Unit position vector
v(3,1) Velocity vector divided by the speed of
Returns
corrected u

Siedelmann, P., (1992). Explanatory Supplement to the Astronomical Almanac, University Science Books, Mill Valley, CA, 129.

Referenced by stellar_reduction().

◆ meci_to_planet()

ml_matrix meci_to_planet ( double  alpha0,
double  delta0,
double  w 
)

Generate the ECI to Planet transformation matrix.

Ref: Montenbruck, O., Pfleger, T., "Astronomy on the Personal Computer, Second Edition."

Parameters
alpha0The right ascension of the planet's pole, measured in degrees.
delta0The declination of the planet's pole, measured in degrees.
wThe angle of rotation about the pole, measured in degrees.
Returns
The transformation matrix from the ECI frame to the planet-fixed frame

References DEGREES_TO_RADIANS.

Referenced by meci_to_earth().

◆ meci_to_earth()

ml_matrix meci_to_earth ( double  jD)

Generate the ECI to eart transformation matrix.

Generate the ECI to eart transformation matrix.

Ref: Montenbruck, O., Pfleger, T., "Astronomy on the Personal Computer, Second Edition."

Parameters
jDJuilan date
Returns
The transformation matrix from the ECI frame to the planet-fixed frame

References jd_to_jcent(), and meci_to_planet().

◆ sun_vector()

ml_matrix sun_vector ( double  jd,
double &  r 
)

Generate the sun vector in the earth-centered inertial frame.

Ref: The 1993 Astronomical Almanac, U.S. Government Printing Office, p. C24.

Parameters
jdJulian date at which the sun vector is to be generated.
rReturns the distance from origin to sun in kms
Returns
Returns the sun vector at a given Julian date

References DEGREES_TO_RADIANS, JD_2000, and REVS_TO_DEGREES.

Referenced by AlignThruster(), gravity_earth::compute_accel(), planetary_accelerations(), and AtmJ70::Update().

◆ moon_vector()

ml_matrix moon_vector ( double  jd,
double &  r 
)

Generate the moon vector in the earth-centered inertial frame.

Ref: The 1993 Astronomical Almanac, U.S. Government Printing Office, p. D46.

Parameters
jdJulian date at which to compute the moon vector.
rReturns the distance from origin to moon in kms
Returns
Returns the moon vector at the given date.

References DEGREES_TO_RADIANS, jd_to_jcent(), RADIUS_EARTH, and REVS_TO_DEGREES.

Referenced by AlignThruster(), gravity_earth::compute_accel(), and planetary_accelerations().

◆ true_earth()

ml_matrix true_earth ( double  jcent)

Computes the matrix from mean of Aries 2000 to earth fixed frame.

Calls earth_rot, earth_nut, and earth_pre in sequence.

    B = B_rot*B_nut*B_pre

Ref: Seidelmann, The Explanatory Supplement to the Astronomical Almanac, p. 20.

Parameters
jcentJulian century at which to compute the true earth matrix.
Returns
Returns the matrix from mean of Aries 2000 to earth fixed frame.

References earth_nut(), earth_pre(), and earth_rot().

Referenced by gravity_earth::compute_accel(), eci_to_llr(), gps_eci_state_from_data(), orbit_closest_point(), and r_ef_from_el().

◆ earth_pre()

ml_matrix earth_pre ( double  jcent)

Computes the earth precession matrix.

Ref: Seidelmann, The Explanatory Supplement to the Astronomical Almanac, p. 103.

Parameters
jcentThe Julian century at which to compute the earth precession matrix.
Returns
Returns the earth precession matrix.

References DEGREES_TO_RADIANS.

Referenced by true_earth().

◆ earth_rot()

ml_matrix earth_rot ( double  jcent)

Computes the earth Greenwich matrix using GMST, that transforms from ECI to Earth-fixed.

Computes the earth Greenwich matrix using GMST, that transforms from ECI to Earth-fixed.

Equivalent to a rotation about the Z axis by the Greenwich mean sidereal time (GMST). Ref: Seidelmann, P. K., The Explanatory Supplement to the Astronomical Almanac, p. 20.

Parameters
jcentJulian century at which to compute the earth Greenwich matrix.
Returns
Returns the earth Greenwich matrix that transforms from ECI to earth-fixed.

References DEGREES_TO_RADIANS, gms_time(), and jcent_to_jd().

Referenced by b_dipole(), mag_field(), and true_earth().

◆ earth_rot_eq()

ml_matrix earth_rot_eq ( double  jcent)

Computes the earth Greenwich matrix using apparent sidereal time.

Computes the earth Greenwich matrix using apparent sidereal time.

Equivalent to a rotation about the Z axis by the Greenwich apparent sidereal time (GAST). Ref: Seidelmann, P. K., The Explanatory Supplement to the Astronomical Almanac, p. 20.

Parameters
jcentJulian century at which to compute the earth Greenwich matrix.
Returns
Returns the earth Greenwich matrix that transforms from ECI to earth-fixed.

References DEGREES_TO_RADIANS, eq_of_equinoxes(), gms_time(), and jcent_to_jd().

◆ earth_nut()

ml_matrix earth_nut ( double  jcent)

The matrix that rotates from the mean axes to the true axes.

Ref: Seidelmann, P. K., The Explanatory Supplement to the Astronomical Almanac, p. 115.

Parameters
jcentThe Julian century at which to calculate the matrix.
Returns
Returns the matrix that rotates from the mean axes to the true axes.

References DEGREES_TO_RADIANS, nut_delta(), and ob_of_ecliptic().

Referenced by true_earth().

◆ nut_delta()

double nut_delta ( double  j_cent,
double &  delta_eps 
)

The changes in longitude and obliquity due to earth nutation.

Ref: Seidelmann, The Explanatory Supplement to the Astronomical Almanac

Parameters
j_centJulian century from JD 2000 for which to compute the changes in longitude and obliquity.
delta_epsReturns the change in obliquity.
Returns
Returns delta_psi, the change in longitude.

References DEGREES_TO_RADIANS, and SECS_TO_HOURS.

Referenced by earth_nut(), and eq_of_equinoxes().

◆ ob_of_ecliptic()

double ob_of_ecliptic ( double  jcent)

Computes the mean obliquity of the ecliptic of date.

Ref: The 1993 Astronomical Almanac, U.S. Government Printing Office, p. B18.

Parameters
jcentThe Julian century at which to compute the mean obliquity.
Returns
Returns the mean obliquity of the ecliptic of date.

Referenced by earth_nut(), and eq_of_equinoxes().

◆ c_ecl_to_eq()

ml_matrix c_ecl_to_eq ( double  jD)

Transformation from eclipic to equatorial.

Transformation from eclipic to equatorial.

If the jd is not input it will use the mean obliquity for J2000.0.

Parameters
jD(1,1) Julian date
Returns
Transformation matrix from the ecliptic plane

References PI.

Referenced by planet_ecliptic_to_orbit().

◆ eq_of_equinoxes()

double eq_of_equinoxes ( double  jcent)

Computes the equation of the equinoxes.

Ref: The Astronomical Almanac for the Year 1993, U.S. Government Printing Office, 1993, p. B6.

Parameters
jcentThe Julian century at which to compute the mean obliquity.
Returns
Returns the mean obliquity of the ecliptic of date.

References DEGREES_TO_RADIANS, nut_delta(), and ob_of_ecliptic().

Referenced by earth_rot_eq().

◆ eclipse_spice()

double eclipse_spice ( const ml_matrix &  pos,
const ml_matrix &  planet_radius,
const ml_matrix &  planet_position,
const ml_matrix &  planet_index,
int  observer 
)

Compute eclipses using Spice data.

Compute eclipses using Spice data.

It automatically determines the center from the observer input.

Parameters
pos(3,1) Position vector of the spacecraft
planet_radius(3,:) Planet radius
planet_position(3,:) Position vector of the planets
planet_index(1,:) Spice index for the radius and posiiton vectors
observer(1,1) Index of orbit center
Returns
Normalized source intensity

References eclipse().

◆ eclipse()

double eclipse ( const ml_matrix &  pos,
const ml_matrix &  l_pos,
const ml_matrix &  p_pos,
double  p_radius,
double  l_radius 
)

Compute eclipses.

Parameters
pos(3,1) Position vector of the spacecraft
l_pos(3,1) Position vector of the light source
p_pos(3,1) Position vector of the planet causing the eclipse
p_radiusRadius of the planet causing the eclipse (default is the earth)
l_radiusRadius of the light source (default is the sun)
Returns
Normalized source intensity

References PI.

Referenced by eclipse_spice().

◆ local_star_position()

ml_matrix local_star_position ( double  jd,
double  lY 
)

Local star positions.

Local star positions.

Parameters
jdJulian date
lYLight years from the sun
Returns
Star matrix in light years

References ra_dec_to_u().

◆ planet_ecliptic_to_orbit() [1/2]

ml_matrix planet_ecliptic_to_orbit ( int  naif_code,
double  jD 
)

Planet orbit rotation frame.

Planet orbit rotation frame.

Parameters
naif_codeCode for planetary system
jDJulian day number
Returns
Rotation matrix

References c_ecl_to_eq().

Referenced by planet_ecliptic_to_orbit().

◆ planet_ecliptic_to_orbit() [2/2]

ml_matrix planet_ecliptic_to_orbit ( char *  planet_name,
double  jD 
)

Generates planet rotation frame.

Uses get_naif_code() and planet_ecliptic_to_orbit().

Parameters
planet_namestring form name
jDJulian day number
Returns
Rotation matrix

References get_naif_code(), and planet_ecliptic_to_orbit().