/*  
 *  - - - - - - - - - - -  
 *   g a l _ s t a r p m  
 *  - - - - - - - - - - -  
 *  
 *  This routine is part of the General Astrodynamics Library  
 *  
 *  Description: 
 *  
 *  Star proper motion:  update star catalog data for space motion.  
 *  
 *  This routine is an independent translation of a FORTRAN routine  
 *  that is part of IAU's SOFA software collection.  
 *  
 *  Status:
 *  
 *     support routine.  
 *  
 *  Given:
 *  
 *     ra1                 d        right ascension (radians), before  
 *     dec1                d        declination (radians), before  
 *     pmr1                d        RA proper motion (radians/year), before  
 *     pmd1                d        Dec proper motion (radians/year), before  
 *     px1                 d        parallax (arcseconds), before  
 *     rv1                 d        radial velocity (km/s, +ve = receding), before  
 *     ep1a                d        "before" epoch, part A (Note 1)  
 *     ep1b                d        "before" epoch, part B (Note 1)  
 *     ep2a                d        "after" epoch, part A (Note 1)  
 *     ep2b                d        "after" epoch, part B (Note 1)  
 *  
 *  Returned:
 *  
 *     *ra2                d        right ascension (radians), after  
 *     *dec2               d        declination (radians), after  
 *     *pmr2               d        RA proper motion (radians/year), after  
 *     *pmd2               d        Dec proper motion (radians/year), after  
 *     *px2                d        parallax (arcseconds), after  
 *     *rv2                d        radial velocity (km/s, +ve = receding), after  
 *     gal_starpm          i        status:  
 *                                  -1    =    system error (should not occur)  
 *                                   0    =    no warnings or errors  
 *                                   1    =    distance overridden (Note 6)  
 *                                   2    =    excessive velocity (Note 7)  
 *                                   4    =    solution didn't converge (Note 8)  
 *                                   else =    binary logical OR of the above warnings  
 *  
 *  Notes:  
 *  
 *  1) The starting and ending TDB epochs ep1a+ep1b and ep2a+ep2b are  
 *     Julian Dates, apportioned in any convenient way between the two  
 *     parts (A and B).  For example, JD(TDB)=2450123.7 could be  
 *     expressed in any of these ways, among others:  
 *  
 *             epna          epnb  
 *  
 *         2450123.7          0.0       (JD method)  
 *         2451545.0      -1421.3       (J2000 method)  
 *         2400000.5      50123.2       (MJD method)  
 *         2450123.5          0.2       (date & time method)  
 *  
 *     The JD method is the most natural and convenient to use in  
 *     cases where the loss of several decimal digits of resolution  
 *     is acceptable.  The J2000 method is best matched to the way  
 *     the argument is handled internally and will deliver the  
 *     optimum resolution.  The MJD method and the date & time methods  
 *     are both good compromises between resolution and convenience.  
 *  
 *  2) 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.  
 *  
 *     The proper motions are the rate of change of the right ascension  
 *     and declination at the catalog epoch and are in radians per TDB  
 *     Julian year.  
 *  
 *     The parallax and radial velocity are in the same frame.  
 *  
 *  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.  
 *  
 *  4) The ra proper motion is in terms of coordinate angle, not true  
 *     angle.  If the catalog uses arcseconds for both ra and dec proper  
 *     motions, the ra proper motion will need to be divided by cos(dec)  
 *     before use.  
 *  
 *  5) Straight-line motion at constant speed, in the inertial frame,  
 *     is assumed.  
 *  
 *  6) An extremely small (or zero or negative) parallax is interpreted  
 *     to mean that the object is on the "celestial sphere", the radius  
 *     of which is an arbitrary (large) value (see the gal_STARPV routine  
 *     for the value used).  When the distance is overridden in this way,  
 *     the status, initially zero, has 1 added to it.  
 *  
 *  7) If the space velocity is a significant fraction of c (see the  
 *     constant VMAX in the routine gal_starpv), it is arbitrarily set to  
 *     zero.  When this action occurs, 2 is added to the status.  
 *  
 *  8) The relativistic adjustment carried out in the gal_starpv routine  
 *     involves an iterative calculation.  If the process fails to  
 *     converge within a set number of iterations, 4 is added to the  
 *     status.  
 *  
 *  Called:
 *  
 *     gal_starpv         star catalog data to space motion pv-vector  
 *     gal_pvu            update a pv-vector  
 *     gal_pdp            scalar product of two p-vectors  
 *     gal_pvstar         space motion pv-vector to star catalog data  
 *  
 *  This revision:
 *  
 *     2006 November 13 ( c version 2008 June 8 )  
 *  
 *  
 *  Copyright (C) 2008 Paul C. L. Willmott. See notes at end.  
 *  
 *-----------------------------------------------------------------------  
 */  
  
#ifndef _GAL_STARPM_H_  
#define _GAL_STARPM_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_starpm  
 (  
    double ra1,  
    double dec1,  
    double pmr1,  
    double pmd1,  
    double px1,  
    double rv1,  
    double ep1a,  
    double ep1b,  
    double ep2a,  
    double ep2b,  
    double *ra2,  
    double *dec2,  
    double *pmr2,  
    double *pmd2,  
    double *px2,  
    double *rv2
 ) ;  
  
__END_DECLS  
  
#endif /* !_GAL_STARPM_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  
 */  
