/*  
 *  - - - - - - - - - - - -
 *   g a l _ c o n s t . h
 *  - - - - - - - - - - - -
 *  
 *  This header file is part of the General Astrodynamics Library  
 *
 *  Description:
 *
 *     This header file defines the standard numerical constants
 *     and support macros.
 *  
 *  Status: 
 *  
 *     Sub-library header file  
 *  
 *  This revision:  
 * 
 *     2009 January 3 
 *  
 *  Copyright (C) 2008, 2009 Paul C. L. Willmott. See notes at end. 
 *  
 *-----------------------------------------------------------------------  
 */  

#ifndef _GAL_CONST_H_  
#define _GAL_CONST_H_ 1  

#include <float.h>

/*
 * -------------------
 * Numerical Constants
 * -------------------
 */

#define GAL_PI     (3.141592653589793238462643)    /* Pi                                              */  
#define GAL_2PI    (6.283185307179586476925287)    /* 2 * Pi                                          */  
#define GAL_R2H    (3.819718634205488058453210)    /* Radians to hours                                */  
#define GAL_R2D    (57.29577951308232087679815)    /* Radians to degrees                              */  
#define GAL_R2S    (13750.98708313975701043156)    /* Radians to seconds                              */  
#define GAL_R2AS   (206264.8062470963551564734)    /* Radians to arc seconds                          */  
#define GAL_H2R    (0.2617993877991494365385536)   /* Hours to radians                                */  
#define GAL_D2R    (1.745329251994329576923691e-2) /* Degrees to radians                              */  
#define GAL_S2R    (7.272205216643039903848712e-5) /* Seconds to radians                              */  
#define GAL_AS2R   (4.848136811095359935899141e-6) /* Arc seconds to radians                          */  
#define GAL_TURNAS (1296000.0)                     /* Arc seconds in a full circle                    */  
#define GAL_U2R    ( GAL_AS2R / 1e7 )              /* Units of 0.1 microarcsecond to radians          */  
#define GAL_MAS2R  ( GAL_AS2R / 1e3 )              /* Milliarcseconds to radians                      */  
#define GAL_DJM    (365250.0)                      /* Days per Julian millennium                      */  
#define GAL_DJC    (36525.0)                       /* Days per Julian century                         */  
#define GAL_DJY    (365.25)                        /* Days per Julian year                            */  
#define GAL_D2S    (86400.0)                       /* Days to Seconds                                 */  
#define GAL_D2M    (1440.0)                        /* Days to Minutes                                 */
#define GAL_D2H    (24.0)                          /* Days to Hours                                   */
#define GAL_J2000  (2451545.0)                     /* Reference epoch (J2000), JD                     */  
#define GAL_MJD0   (2400000.5)                     /* Modified Julian Date Day 0                      */  
#define GAL_MJ2000 (51544.5)                       /* Reference epoch (J2000), MJD                    */  
#define GAL_KM2M   (1000.0)                        /* Kilometers to metres                            */
#define GAL_AU03   (149597870691.0)                /* Astronomical Unit IERS 2003 / DE405 metres  
    */
#define GAL_RESU76 (6.96e8)                        /* Equatorial Radius of the Sun IAU76 metres       */
#define GAL_SRP96  (4.56e-6)                       /* Solar Radiation Pressure @ 1 AU IERS 1996 Nm^-2 */
/*
 * -------------------------------------
 * Constants for the Solar System bodies
 * -------------------------------------
 */
 
enum {
  GAL_SSB_SU = 0,  /* The Sun               */
  GAL_SSB_ME = 1,  /* Mercury               */
  GAL_SSB_VE = 2,  /* Venus                 */
  GAL_SSB_EA = 3,  /* Earth                 */
  GAL_SSB_MA = 4,  /* Mars                  */
  GAL_SSB_JU = 5,  /* Jupiter               */
  GAL_SSB_SA = 6,  /* Saturn                */
  GAL_SSB_UR = 7,  /* Uranus                */
  GAL_SSB_NE = 8,  /* Neptune               */
  GAL_SSB_EB = 9,  /* Earth-Moon Barycenter */
  GAL_SSB_PL = 10, /* Pluto                 */
  GAL_SSB_MO = 11, /* The Moon              */
} ;
  
/*  
 * Macro to simulate the FORTRAN SIGN function  
 */  
  
#define GAL_SIGN( a, b) fabs ( a ) * ( ( ( b ) >= 0.0 ) ? 1.0 : -1.0 )  

/*
 * Macro for Maximum value
 */
 
#define GAL_MAX( a, b ) ( a ) >= ( b ) ? ( a ) : ( b )

/*
 * Macro for Minimum value
 */
 
#define GAL_MIN( a, b ) ( a ) <= ( b ) ? ( a ) : ( b )

/*
 * ------------------------------------------
 * Constants for routine return status values
 * ------------------------------------------
 */
 
enum {
  GAL_SUCCESS = 0,
  GAL_FAILURE = 1,
} ;

/*
 * Constant for undefined results
 */
 
#define GAL_UNDEFINED DBL_MAX

#endif /* !_GAL_CONST_H_ */  

/*  
 *  gal - General Astrodynamics Library  
 *  Copyright (C) 2008, 2009 Paul C. L. Willmott  
 *  
 *  This program is free software; you can redistribute it and/or modify  
 *  it under the terms of the GNU General Public License as published by  
 *  the Free Software Foundation; either version 2 of the License, or  
 *  (at your option) any later version.  
 *  
 *  This program is distributed in the hope that it will be useful,  
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of  
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
 *  GNU General Public License for more details.  
 *  
 *  You should have received a copy of the GNU General Public License along  
 *  with this program; if not, write to the Free Software Foundation, Inc.,  
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.  
 *  
 *  Contact:  
 *  
 *  Paul Willmott  
 *  vp9mu@amsat.org  
 */  
