/*  
 *  - - - - - - - - - - - 
 *   g a l _ p v 2 k e p  
 *  - - - - - - - - - - - 
 *  
 *  This routine is part of the General Astrodynamics Library  
 *
 *  Description:
 *
 *     This routine computes the classical orbital elements from position and velocity.
 *  
 *  Status: 
 *  
 *     Classical Model.  
 *  
 *  Given:  
 *
 *     gm             double        Gravitational parameter
 *     pv             d[2][3]       Position & Velocity Vectors
 *  
 *  Returned:  
 *  
 *     *sma             d           Semi-Major Axis (m)
 *     *ecc             d           Eccentricity
 *     *raan            d           Longitude of the ascending mode (radians) 
 *     *argp            d           Argument of Pericentre (radians) 
 *     *ma              d           Mean Anomaly (radians)
 *     *inc             d           Inclination (radians)
 *     *p               d           Semi-Latus Rectum (m)
 *     *v               d           True Anomaly (radians)
 *     *truelon         d           True Longitude (radians)
 *     *u               d           Argument of Latitude (radians)
 *     *lonper          d           True Longitude of Periapsis (radians)
 * 
 *
 *  Notes:
 *
 *  1) If a parameter is undefined the value GAL_UNDEFINED is returned. The user should check the return values
 *     for undefined cases. GAL_UNDEFINED is defined in gal_const.h .
 *
 *  Called:
 *
 *     gal_pxp                      cross product of two p vectors
 *     gal_pm                       modulus of a p vector
 *     gal_pdp                      p vector dot product
 *     gal_anp                      Normalize angle into the range 0 <= a < 2pi
 *
 *  References:
 *
 *     Fundamentals of Astrodynamics and Applications
 *     Vallado, David A. Second Edition 2004
 *     Pages 118-122
 *
 *     Satellite Orbits
 *     Oliver Montenbruck, Eberhard Gill
 *     Springer 2005
 *     Pages 28-32
 *
 *     Methods of Orbit Determination for the Micro Computer
 *     Boulet, Dan
 *     Willmann-Bell 1991
 *     Pages 149-157
 *
 *  This revision:  
 * 
 *     2008 September 20 
 *  
 *  Copyright (C) 2008 Paul C. L. Willmott. See notes at end. 
 *  
 *-----------------------------------------------------------------------  
 */  

#ifndef _GAL_PV2KEP_H_  
#define _GAL_PV2KEP_H_ 1  

  
#undef  __BEGIN_DECLS  
#undef  __END_DECLS  
#ifdef  __cplusplus  
#define __BEGIN_DECLS extern "C" {  
#define __END_DECLS }  
#else  
#define __BEGIN_DECLS /* empty */  
#define __END_DECLS   /* empty */  
#endif
  
__BEGIN_DECLS  

void
gal_pv2kep
  (
    double gm,
    double pv[2][3],
    double *sma,
    double *ecc, 
    double *raan,
    double *argp,
    double *ma,
    double *inc,
    double *p,
    double *v,
    double *truelon,
    double *u,
    double *lonper
  ) ;
 
__END_DECLS  
  
#endif /* !_GAL_PV2KEP_H_ */ 

/*
 *  gal - General Astrodynamics Library  
 *  Copyright (C) 2008 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  
 */  
  
