?? sgp4ext.cpp
字號:
/* ----------------------------------------------------------------
*
* sgp4ext.cpp
*
* this file contains extra routines needed for the main test program for sgp4.
* these routines are derived from the astro libraries.
*
* companion code for
* fundamentals of astrodynamics and applications
* 2007
* by david vallado
*
* (w) 719-573-2600, email dvallado@agi.com
*
* current :
* 2 apr 07 david vallado
* fix jday floor and str lengths
* updates for constants
* changes :
* 14 aug 06 david vallado
* original baseline
* ---------------------------------------------------------------- */
#include "sgp4ext.h"
#include "sgp4unit.h"
#define pi 3.14159265358979323846
double sgn
(
double x
)
{
if (x < 1.0)
{
return -1;
}
else if (x > 1.0)
{
return 1;
}
return 0.0;
} // end sgn
/* -----------------------------------------------------------------------------
*
* function mag
*
* this procedure finds the magnitude of a vector. the tolerance is set to
* 0.000001, thus the 1.0e-12 for the squared test of underflows.
*
* author : david vallado 719-573-2600 1 mar 2001
*
* inputs description range / units
* vec - vector
*
* outputs :
* vec - answer stored in fourth component
*
* locals :
* none.
*
* coupling :
* none.
* --------------------------------------------------------------------------- */
double mag
(
double x[3]
)
{
return sqrt(x[0]*x[0] + x[1]*x[1] + x[2]*x[2]);
} // end mag
/* -----------------------------------------------------------------------------
*
* procedure cross
*
* this procedure crosses two vectors.
*
* author : david vallado 719-573-2600 1 mar 2001
*
* inputs description range / units
* vec1 - vector number 1
* vec2 - vector number 2
*
* outputs :
* outvec - vector result of a x b
*
* locals :
* none.
*
* coupling :
* mag magnitude of a vector
---------------------------------------------------------------------------- */
void cross
(
double vec1[3], double vec2[3], double outvec[3]
)
{
outvec[0]= vec1[1]*vec2[2] - vec1[2]*vec2[1];
outvec[1]= vec1[2]*vec2[0] - vec1[0]*vec2[2];
outvec[2]= vec1[0]*vec2[1] - vec1[1]*vec2[0];
} // end cross
/* -----------------------------------------------------------------------------
*
* function dot
*
* this function finds the dot product of two vectors.
*
* author : david vallado 719-573-2600 1 mar 2001
*
* inputs description range / units
* vec1 - vector number 1
* vec2 - vector number 2
*
* outputs :
* dot - result
*
* locals :
* none.
*
* coupling :
* none.
*
* --------------------------------------------------------------------------- */
double dot
(
double x[3], double y[3]
)
{
return (x[0]*y[0] + x[1]*y[1] + x[2]*y[2]);
} // end dot
/* -----------------------------------------------------------------------------
*
* procedure angle
*
* this procedure calculates the angle between two vectors. the output is
* set to 999999.1 to indicate an undefined value. be sure to check for
* this at the output phase.
*
* author : david vallado 719-573-2600 1 mar 2001
*
* inputs description range / units
* vec1 - vector number 1
* vec2 - vector number 2
*
* outputs :
* theta - angle between the two vectors -pi to pi
*
* locals :
* temp - temporary real variable
*
* coupling :
* dot dot product of two vectors
* --------------------------------------------------------------------------- */
double angle
(
double vec1[3],
double vec2[3]
)
{
double small, undefined, magv1, magv2, temp;
small = 0.00000001;
undefined = 999999.1;
magv1 = mag(vec1);
magv2 = mag(vec2);
if (magv1*magv2 > small*small)
{
temp= dot(vec1,vec2) / (magv1*magv2);
if (fabs( temp ) > 1.0)
temp= sgn(temp) * 1.0;
return acos( temp );
}
else
return undefined;
} // end angle
/* -----------------------------------------------------------------------------
*
* function asinh
*
* this function evaluates the inverse hyperbolic sine function.
*
* author : david vallado 719-573-2600 1 mar 2001
*
* inputs description range / units
* xval - angle value any real
*
* outputs :
* arcsinh - result any real
*
* locals :
* none.
*
* coupling :
* none.
*
* --------------------------------------------------------------------------- */
double asinh
(
double xval
)
{
return log( xval + sqrt( xval*xval + 1.0 ) );
} // end asinh
/* -----------------------------------------------------------------------------
*
* function newtonnu
*
* this function solves keplers equation when the true anomaly is known.
* the mean and eccentric, parabolic, or hyperbolic anomaly is also found.
* the parabolic limit at 168
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -