/*  
 *  - - - - - - - - - - -  
 *   g a l _ p v s t a r  
 *  - - - - - - - - - - -  
 *  
 *  This routine is part of the General Astrodynamics Library  
 *  
 *  Description: 
 *  
 *  Convert star position+velocity vector to catalog coordinates.  
 *  
 *  This routine is an independent translation of a FORTRAN routine  
 *  that is part of IAU's SOFA software collection.  
 *  
 *  Status:
 *  
 *     support routine.  
 *  
 *  Given (Note 1):  
 *     pv               d[2][3]     pv-vector (AU, AU/day)  
 *  
 *  Returned (Note 2):  
 *     *ra                 d        right ascension (radians)  
 *     *dec                d        declination (radians)  
 *     *pmr                d        RA proper motion (radians/year)  
 *     *pmd                d        Dec proper motion (radians/year)  
 *     *px                 d        parallax (arcsec)  
 *     *rv                 d        radial velocity (km/s, positive = receding)  
 *     gal_pvstar          i        status:  
 *                                   0 = OK  
 *                                  -1 = superluminal speed (Note 5)  
 *                                  -2 = null position vector  
 *  
 *  Notes:  
 *  
 *  1) The specified pv-vector is the coordinate direction (and its rate  
 *     of change) for the epoch at which the light leaving the star  
 *     reached the solar-system barycenter.  
 *  
 *  2) The star data returned by this routine are "observables" for an  
 *     imaginary observer at the solar-system barycenter.  Proper motion  
 *     and radial velocity are, strictly, in terms of barycentric  
 *     coordinate time, TCB.  For most practical applications, it is  
 *     permissible to neglect the distinction between TCB and ordinary  
 *     "proper" time on Earth (TT/TAI).  The result will, as a rule, be  
 *     limited by the intrinsic accuracy of the proper-motion and radial-  
 *     velocity data;  moreover, the supplied pv-vector is likely to be  
 *     merely an intermediate result (for example generated by the  
 *     routine gal_starpv), so that a change of time unit will cancel  
 *     out overall.  
 *  
 *     In accordance with normal star-catalog conventions, the object's  
 *     right ascension and declination are freed from the effects of  
 *     secular aberration.  The frame, which is aligned to the catalog  
 *     equator and equinox, is Lorentzian and centered on the SSB.  
 *  
 *     Summarizing, the specified pv-vector is for most stars almost  
 *     identical to the result of applying the standard geometrical  
 *     "space motion" transformation to the catalog data.  The  
 *     differences, which are the subject of the Stumpff paper cited  
 *     below, are:  
 *  
 *     (i) In stars with significant radial velocity and proper motion,  
 *     the constantly changing light-time distorts the apparent proper  
 *     motion.  Note that this is a classical, not a relativistic,  
 *     effect.  
 *  
 *     (ii) The transformation complies with special relativity.  
 *  
 *  3) Care is needed with units.  The star coordinates are in radians  
 *     and the proper motions in radians per Julian year, but the  
 *     parallax is in arcseconds; the radial velocity is in km/s, but  
 *     the pv-vector result is in AU and AU/day.  
 *  
 *  4) The proper motions are the rate of change of the right ascension  
 *     and declination at the catalog epoch and are in radians per Julian  
 *     year.  The RA proper motion is in terms of coordinate angle, not  
 *     true angle, and will thus be numerically larger at high  
 *     declinations.  
 *  
 *  5) Straight-line motion at constant speed in the inertial frame is  
 *     assumed.  If the speed is greater than or equal to the speed of  
 *     light, the routine aborts with an error status.  
 *  
 *  6) The inverse transformation is performed by the routine gal_starpv.  
 *  
 *  Called:
 *  
 *     gal_pn             decompose p-vector into modulus and direction  
 *     gal_pdp            scalar product of two p-vectors  
 *     gal_sxp            multiply p-vector by scalar  
 *     gal_pmp            p-vector minus p-vector  
 *     gal_pm             modulus of p-vector  
 *     gal_ppp            p-vector plus p-vector  
 *     gal_pv2s           pv-vector to spherical  
 *     gal_anp            normalize angle into range 0 to 2pi  
 *  
 *  References:  
 *  
 *     Stumpff, P., Astron.Astrophys. 144, 232-240 (1985).  
 *  
 *  This revision:
 *  
 *     2006 November 13 ( c version 2008 June 8 )  
 *  
 *  
 *  Copyright (C) 2008 Paul C. L. Willmott. See notes at end.  
 *  
 *-----------------------------------------------------------------------  
 */  
  
#ifndef _GAL_PVSTAR_H_  
#define _GAL_PVSTAR_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  
  
int  
gal_pvstar  
 (  
    double pv[2][3],  
    double *ra,  
    double *dec,  
    double *pmr,  
    double *pmd,  
    double *px,  
    double *rv
 ) ;  
  
__END_DECLS  
  
#endif /* !_GAL_PVSTAR_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  
 */  
