/* > sgdp4h.h * * * Paul S. Crawford and Andrew R. Brooks * Dundee University * * NOTE ! * This code is supplied "as is" and without warranty of any sort. * * (c) 1994-2004, Paul Crawford, Andrew Brooks * * * 2.00 psc Sun May 28 1995 - Modifed for non-Dundee use. * */ #ifndef _SGDP4H_H #define _SGDP4H_H /* * Set up standard system-dependent names UNIX, LINUX, RISCOS, MSDOS, WIN32 */ #if defined( unix ) # define UNIX # if defined( linux ) && !defined( LINUX ) # define LINUX # endif #elif defined( __riscos ) && !defined( RISCOS ) # define RISCOS #elif !defined( MSDOS ) && !defined( WIN32 ) && !defined( __CYGWIN__ ) # define MSDOS #endif /* * Include files */ #include #include #include #include #include #include #include #ifdef UNIX #include #endif #ifdef SUN4 #include #endif #ifdef sun #include /* solaris 7 has struct timeval in here */ #include /* for sincos() which is in libsunmath */ #endif #ifdef linux #include void sincos(double x, double *s, double *c); /* declared where? */ #endif /* * ================= SYSTEM SPECIFIC DEFINITIONS ===================== */ /* Use INLINE keyword when declaring inline functions */ #ifdef WIN32 #define INLINE __inline #elif defined( MSDOS ) #define INLINE #else /*UNIX?*/ #define INLINE inline #endif /* Sun C compiler has automatic inline and doesn't understand inline keyword */ #ifdef __SUNPRO_C #undef INLINE #define INLINE #define MACROS_ARE_SAFE #endif /* Some very common constants. */ #ifndef M_PI #define M_PI 3.141592653589793 #endif /* MSDOS */ #ifndef PI #define PI M_PI #endif #define TWOPI (2.0*PI) /* Optimising compiler will deal with this! */ #define PB2 (0.5*PI) #define PI180 (PI/180.0) #define SOLAR_DAY (1440.0) /* Minutes per 24 hours */ #define SIDERIAL_DAY (23.0*60.0 + 56.0 + 4.09054/60.0) /* Against stars */ #define EQRAD (6378.137) /* Earth radius at equator, km */ #define LATCON (1.0/298.257) /* Latitude radius constant */ #define ECON ((1.0-LATCON)*(1.0-LATCON)) #define JD1900 2415020.5 /* Julian day number for Jan 1st, 00:00 hours 1900 */ /* * =============================== MACROS ============================ * * * Define macro for sign transfer, double to nearest (long) integer, * to square an expression (not nested), and A "safe" square, uses test * to force correct sequence of evaluation when the macro is nested. */ /* * These macros are safe since they make no assignments. */ #define SIGN(a, b) ((b) >= 0 ? fabs(a) : -fabs(a)) /* Coordinate conversion macros */ #define DEG(x) ((x)/PI180) #define RAD(x) ((x)*PI180) #define GEOC(x) (atan(ECON*tan(x))) /* Geographic to geocentric. */ #define GEOG(x) (atan(tan(x)/ECON)) /* * All other compilers can have static inline functions. * (SQR is used badly here: do_cal.c, glat2lat.c, satpos.c, vmath.h). */ static INLINE int NINT(double a) { return (int)(a > 0 ? a+0.5 : a-0.5); } static INLINE long NLONG(double a) { return (long)(a > 0 ? a+0.5 : a-0.5); } static INLINE double DSQR(double a) { return(a*a); } static INLINE float FSQR(float a) { return(a*a); } static INLINE int ISQR(int a) { return(a*a); } static INLINE double DCUBE(double a) { return(a*a*a); } static INLINE float FCUBE(float a) { return(a*a*a); } static INLINE int ICUBE(int a) { return(a*a*a); } static INLINE double DPOW4(double a) { a*=a; return(a*a); } static INLINE float FPOW4(float a) { a*=a; return(a*a); } static INLINE int IPOW4(int a) { a*=a; return(a*a); } static INLINE double DMAX(double a,double b) { if (a>b) return a; else return b; } static INLINE float FMAX(float a, float b) { if (a>b) return a; else return b; } static INLINE int IMAX(int a, int b) { if (a>b) return a; else return b; } static INLINE double DMIN(double a,double b) { if (a