You are on page 1of 13

Astrodynamics Software

Companion code to Fundamentals of Astrodynamics and Applications by David Vallado, 2013


This code has accumulated over the years, starting with computer libraries used while I taught at the Air Force Academy. With the publication of my book, the code has been on the Internet in some form since about 1998. The versions are "relatively" consistent, but not all are up to date. The MatLab and C++ versions are generally the most up to date, and the SGP4 routines are all current. Questions should be addressed to me at dvallado@agi.com. Also, please note that Jeff Beck deserves the credit for translating the SGP4 MatLab version. You can contact him at beckja@alumni.lehigh.edu. Note that the more complex procedures (such as numerical propagation) are best left to a sophisticated program like Systems Toolkit (www.agi.com). There are free educational resources available for this tool. cpp for mat pas Book Ref Name Operation

ASTMATH
Mathematical functions ---------- miscellaneous functions ---------factorial factorial function binomial binomial sgn transfer sign modfunc modulo power base to an exponent log log values min minimum value max maximum value plane plane from 3 points ---------- trigonometric functions ---------tan tangent cot cotangent csc cosecant sec secant atan2 inverse tangent resolving quadrant asin inverse sine acos inverse cosine cosh hyperbolic cosine acosh inverse hyperbolic cosine sinh hyperbolic sine asinh inverse hyperbolic sine tanh hyperbolic tangent atanh inverse hyperbolic tangent ---------- vector functions ---------dot dot product of 2 vectors cross cross product of 2 vectors mag magnitude of a vector norm unit vector rot1 rotate about the 1st axis rot2 rotate about the 2nd axis rot3 rotate about the 3rd axis rot1mat create rotation matrix with an angle about the 1st axis rot2mat create rotation matrix with an angle about the 2nd axis rot3mat create rotation matrix with an angle about the 3rd axis addvec add 2 vectors subvec subtract 2 vectors add3vec add 3 vectors lncom1 combine a constant and a vector lncom2 combine 2 constants and 2 vectors lncom3 combine 3 constants and 3 vectors angle angle between 2 vectors writevec write out a vector ---------- polynomial functions ---------polyfit dmulrsub factor factors of a polynomial - iterative quadratic roots of a quadratic cubic roots of a cubic quartic roots of a quartic cubicspl find the coefficients of a cubic spline (fit all 4 points) cubicinterp perform cubic interpolation (fit ll 4 points) parabbln parabolic blending

974 975 976 556 556 979

981 cubicspl1 cubic splining 983 quarticbln perform quartic blending ---------- matrix functions ---------initmatrix initialize matrix pointers delmatrix delete matrix pointers getval get value from a matrix element assignval assign a value to a matrix element matscale scale a matrix matmult multiply 2 matrices matadd add 2 matrices matsub subtract 2 matrices mattrans transpose a matrix matvecmult multiply a vector times a matrix makemat ludecomp lubksub matinverse matrix inverse writemat readmat filewritemat fileexpwritemat determinant determinant of a matrix

ASTTIME
Time functions INITTIME initialize time data files getintmon find integer number of a character month getintday find integer number of a character day dayofweek find integer number of a character day of week DAYLIGHTST find start/stop jd of daylight savings time JDay julian date 1800-2100 JDayALL julian date all times DAY2SMDHMS days to month, day, hr, min, sec INVJDay inverse julian date FINDDAYS find days given month, day, yr, hr, min, sec GSTIME greenwich sidereal time gstim0 greenwich sidereal time at the beginning of the year LSTIME local sidereal time SUNRISESET sun rise and set times MOONRISESET moon rise and set times HMS_SEC convert between hr, min, sec and sec HMS_UT convert between hr, min, sec and ut HMS_RAD convert between hr, min, sec and rad DMS_RAD convert between deg, min, sec and rad jd2sse Julian date to sec since epoch convtime convert utc to alterante time systems

188 189 190 208 207 193 195 194 283 292 205 204 203 201

ASTREDUC
* * = Matlab requires a function for each direction, **= Pascal routines move between eci and each frame ---------- fk5 functions ---------228 iau76fk5itrf_gcrf includes ddpsi and ddeps 228 iau76fk5itrf_j2k ecef to j2000 - no ddpsi, ddeps 228 iau76fk5itrf_mod 228 iau76fk5pef_gcrf 228 iau76fk5tod_gcrf 228 iau76fk5mod_gcrf 236 iau76fk5teme_pef preferred way to convert from teme 236 iau76fk5teme_j2k iau80in 228 fundarg 228 precess 228 nutation 228 sidereal 228 polarm 236 truemean 240 fk4

* * *

** ** ** ** ** **

---------- iau 2000 functions ---------217 framebias iau00in 217 iau00xys 217 iau00era 217 icrsgst 217 icrspna 217 icrspnb 217 iau00i2f 217 iau00f2i

AST2BODY
121 126 117 117 116 116 117 117 163 164 71 85 73 85 101 134 179 Two-body operations rv2coe position and velocity vectors to classical orbital elements coe2rv classical orbital elements to position and velocity vectors flt2rv flight orbital elements to position and velocity vectors rv2flt position and velocity vectors to flight orbital elements eq2rv equinoctial orbital elements to position and velocity vectors rv2eq position and velocity vectors to equinoctial orbital elements adbar2rv adbarv orbital elements to position and velocity vectors rv2adbar position and velocity vectors to adbarv orbital elements rv2rsw position and velocity vectors to rsw rv2ntw position and velocity vectors to ntw FINDC2C3 c2 and c3 functions for universal variables NEWTONE Kepler iteration for Eccentric anomaly to true anomaly NEWTONM Kepler iteration for Mean anomaly to true anomaly NEWTONNU Kepler iteration for True anomaly to mean anomaly KEPLER Kepler two-body propagation using universal variables FINDTOF find tof for two vectors and semi-parameter ijk2llA position vector to lat, lon, alt - almanac ijk2llE position vector to lat, lon, alt - escobal ijk2llB position vector to lat, lon, alt - borkowski gc_gd conversion between geocentric and geodetic latitude SIGHT line of sight between 2 position vectors SUN analytic position of the sun SunIll illumination of the sun at the earth surface MOON analytic moon position MoonIll illumination of the moon at the earth surface LIGHT position vector in the sunlight or not CHECKHITEARTH check if a satellite hits the earth during a transfer SATFOV find parameters associated with fov geometries RNGAZ find lat lon of target given lat lon rng and az of launch PATH find range and azimuth between two ground locations ASTIOD Initial Orbit Determination routines SITE site location (ecef) ---------- angles-only functions ---------ANGLESLAPLACE laplace method ANGLESGAUSS gaussian method ANGLESDR double-r iteration Doubler performs the iteration work for double-r iteration ---------- measurement conversion functions ---------RV_RADEC conversion between position and velocity vectors and radec RV_TRADEC conversion between positiontopocentric and velocity radec vectors and RV_RAZEL conversion between position and velocity vectors and range, RV_ELATLON conversion between position and velocity vectors and ecliptic RVSEZ_RAZEL conversion between topocentric position and velocity vectors RADEC_ELATLON conversion between radec and ecliptic lat, lon RADEC_AZEL conversion between radec and az, el ---------- 3 position vector functions ---------GIBBS gibbs method HERRGIBBS herrick gibbs method ---------- 2 position vector functions ---------LAMBERTUNIV universal variable formulation LAMBERTBATTIN battin formulation in work

148 310 271 311 290 311 310 500 845 843 843

TARGET

SGP4
---------- sgp4 mathematical routines ---------initl initialize dsinit initialize deep space dspace deep space dpper deep space peruturbations dscom deep space common routines sgp4init first call to initialize sgp4 routine call for propagation getgravc gravity constants for sgp4 ---------- sgp4 io routines ---------twoline2rv read tle data into variables twoline2rvold read tle data into variables ---------- sgp4 test routines ---------testxxx test program for sgp4 in various languages (xxx)

ASTMANV
327 327 335 346 349 350 355 355 364 370 397 410 413 414 Maneuver operations Hohmann Hohmann transfer burns BiElliptic bi-elliptic burns OneTangent one tangent burns IOnlyChg inclination only burns NodeOnlyChg node only burns IandNodeChg inclination and node changes MinCombinedPlaneChg min combined plane changes CombinedPlaneChg combined plane changes Rendezvous simple rendezvous calculations NonCoplanarRendz non coplanar rendezvous HillsR hills position calcualtions HillsV hill velocity calculations Cow2Hill cowell to hill transfrom Hill2Cow hill to cowell transform

ASTPERT
Perturbation functions: PKEPLER perturbed propagation J2DragPert PREDICT determine site visibility Deriv InitGravityField LegPoly FullGeop PERTACCEL setup forces for numerical integrator PDERIV 526 RK4 4th order Runge Kutta 526 RKF45 Cowell ATMOS 687 645 900 593 MSISCOM MSIS00 Common MSIS functions NRLMSIS-00 atmoshperic model

ASTINTER
Interplanetary functions 995 PlanetRV 47 Interplanetary ASTDC.FOR in work

Differential Correction functions nonlin find nonlinear ls solution findatwaatwb find atwa and atwb matrices leastsquares simple least squares solution for orbit determination sequential sequential batch orbit determination findphi find state transition matrix findphia find state transition matrix findh find obersvation matrix lkf linearized kalman filter for orbit problem ekf extended kalman filter for orbit problem

ASTUTIL
Utility functions. Mostly for character operations copy copy a string to another RmSpcs remove spaces from a string GETPART get an integer value from a string GETPARTL get a long integer value from a string GetPartR get a real value from a string upcasestr change a string to upper case

DCF.FOR Sample Differential Correction program dcf

in work

CONSTANTS
Sample Test Program constastro astrodynamic constants constmath math constants TESTASTF.FOR Sample Test Program testastf in work

Astrodynamics Software
Companion code to Fundamentals of Astrodynamics and Applications by David Vallado, 2013

These routines provide solutions for the algorithms in the text. Some are integrated and combined with others, while most are stand-alone. Some of the m involved problems are best solved with a program like Satellite Toolkit (www.agi.com).

Algorithm 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

Name Find c 2 c 3 KepEqtnE KepEqtnP KepEqtnH n to Anomaly Anomaly to n KeplerCOE Kepler RV2COE COE2RV FindTOF ECEF to LatLon ECEF to LatLon Julian Date LSTime ConvTime DMStoRad RadtoDMS HMStoRad RadtoHMS TimeToHMS JDtoGregorianDate IAU 2000 CIO-based IAU-76/FK5 Reduction Geocentric Radec Topocentric RAZEL AzElToRaDec Sun SunriseSet Moon MoonRiseSet PlanetRV Shadow SIGHT Hohmann Transfer Bi-elliptic Transfer One-Tangent Burn Inclination Only Change in the Ascending NodeCircular Combined Changes to i and QCircular Minimum Combined Plane Change Fixed-Dv Maneuvers

Page 71 73 77 79 85 85 89 101 121 126 134 179 180 189 194 201 203 204 204 205 205 208 224 233 262 264 269 272 281 285 290 292 298 303 310 327 327 335 346 349 350 355 358

Matlab name findc2c3.m newtonm.m newtonm.m newtonm.m

Test Program

kepler.m rv2coe.m coe2rv.m findtof.m ijk2ll.m ijk2llb.m jday.m lstime.m convtime.m dms2rad.m rad2dms.m hms2rad.m rad2hms.m

testred.m testred.m

rv2razel.m sun.m sunriset.m moon.m moonrise.m

sight.m hohmann.m biellip.m onetang.m ionlylchg.m nodeonly.m combined.m combpln.m

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75

Circular Coplanar Phasing (Same Orbits) Circular Coplanar Phasing (Different Orbits) Noncoplanar Phasing Hills Equations Hill2Eci ECI2Hill Site-Track Angles-Only Gauss Angles-Double-r Gibbs Herrick-Gibbs Lamberts ProblemMinimum Energy LambertGausss Solution LambertUniversal Variables LambertBattin Method Hit Earth Target Encke Ap2Kp Conversion Numerical Integration PKepler Nominal State Differential Correction Kalman FilterLinear System Linearized Kalman Filter Extended Kalman Filter Repeat Groundtrack Maintain Repeat Groundtrack Minimum Altitude Variation Predict Rise/Set ANCAS

364 365 370 397 413 414 426 438 440 456 462 471 475 488 491 500 501 523 556 588 687 760 762 779 784 786 862 868 874 900 950 915

rendz.m rendz.m noncolpr.m hillsr.m hill2eci.m eci2hill.m site.m

testhill.m

gibbs.m hgibbs.m

testgib.m testgib.m

lambertu.m lambertb.m checkhit.m target.m

testlam.m

pkepler.m

repeatgt.m

predict.m

e most are stand-alone. Some of the more .com).

Also uses

many many

kbatt.m

seebat.m

Astrodynamics Software
Companion code to Fundamentals of Astrodynamics and Applications by David Vallado, 2013

These routines provide solutions for the examples in the text. Some are integrated and combined with others, while most are stand-alone. Some of the m involved problems are best solved with a program like Satellite Toolkit (www.agi.com).

Example 1-1 2-1 2-2 2-3 2-4 2-5 2-6 3-1 3-2 3-3 3-4 3-5 3-6 3-7 3-8 3-9 3-10 3-11 3-12 3-13 3-14 3-15 4-1 5-1 5-2 5-3 5-4 5-5 5-6 5-7 6-1 6-2 6-3 6-4 6-5 6-6 6-7 6-8 6-9 6-10 6-11 6-12 6-13 6-14

Name Determine semimajor axis Keplers equation Keplers equation Keplers equation Keplers problem RV2COE COE2RV Determine site coordinates Finding station coordinates Convert ECEF to Lat Lon Determine Julian Date Find GMST/LST Find GMST/LST Calculate Dynamical time Find dms find hms HMS to time find day of year convert ymdhms find gregorian date fromJD perform iau2000 reduction perform iau76/fk5 reduction finding observation values Sun position vector Sunrise and sunset moon position vector Moon rise/set Planetary location Sight/LIGHT Finding parallax finding Hohmann transfer Finding bi-elliptic transfer Finding one tangent burn Delta V inclination only Delta V Right Acsenion of the node Delta V Inclination and node Combined Manuevers Rendezvous same orbit Rendezvous different orbit Rendezvous non-coplanar orbits Cont Thrust, Earth to mars Cont thrust, LEO to GEO Low Thrust, LEO to GEO Hills Equations, position

Page 31 74 77 79 102 122 127 148 152 179 190 194 196 201 205 205 206 206 207 209 225 235 275 283 286 290 294 299 310 315 328 329 336 346 349 351 358 365 367 371 382 383 388 397

Test Program ex1_1.m ex2_2.m ex2_2.m ex2_2.m ex2_4.m ex2_5.m includes additional coe and rv tests ex2_6.m ex3_1.m ex3_2.m ex3_3.m ex3_4.m ex3_5.m ex3_6.m ex3_7.m ex3_8.m ex3_9.m

ex3_1415.m ex3_1415.m ex4_1.m ex5_1.m ex5_2.m ex5_3.m ex5_2.m ex5_6.m ex6_1.m ex6_2.m ex6_3.m ex6_4.m ex6_5.m ex6_6.m ex6_7.m ex6_8.m ex6_9.m ex6_10.m

in work

ex6_14.m

6-15 7-1 7-2 7-3 7-4 7-5 8-1 8-2 8-3 8-4 9-1 10-1 10-2 10-3 10-4 10-5 10-6 11-1 11-2 11-3 11-4 11-5 11-6 11-7 11-8

Hills Equations, velocity Site-track Angles-only IOD Gibbs IOD Herrick-Gibbs Lamberts problem direct integration numerical integration Normalizing gravitational coefficients Finding atmospheric density Analytical integration Linear least sqaures Linear least sqaures non linear least squares Least Squares for Orbit determination Sequential batch least squares linear Kalman filter Finding FOV parameters Finding Sun Synchronous orbits Finding preliminary orbital elements Maintaining repeat ground track Maintaining minimum altitude variations Prediciting satellite look angles Prediciting rise/set times Determining a close approach

411 427 443 457 463 494 518 519 544 563 610 733 742 753 763 768 779 848 853 880 882 884 901 907 917

ex6_15.m ex7_1.m ex7_2.m ex7_34.m ex7_34.m testlam.m

includes comparison of gibbs and hgi in work

ex10_1.m ex10_2.m ex10_3.m ex10_4.m ex10_5.m ex11_1.m ex11_3.m ex11-4.m ex11-5.m in work

, while most are stand-alone. Some of the more ww.agi.com).

includes additional coe and rv tests

includes comparison of gibbs and hgibbs techniques