/***************************************************************

   M_TO_POS.C

   Routines for converting latitude and longitude
   differences in meters into degrees.  They are the
   inverses of the functions in POS_TO_M.C.  They use the
   first few terms in the approximations given by .......

   Header: POS_TO_M.H   (temporary)

   Reference: American Practical Navigator, Vol II, 1975 Edition, p 5 

***************************************************************/
#include <math.h>

#ifndef M_PI
#define M_PI		3.14159265358979323846
#endif

#if PROTOTYPE_ALLOWED
double meters_to_dlon(double dmeters, double lat)
#else
double meters_to_dlon(dmeters, lat)
double dmeters, lat;
#endif
{
   double rlat, p;

   rlat = lat * M_PI/180;
   p = 111415.13 * cos(rlat) - 94.55 * cos(3*rlat);
   return(dmeters / p);
}

#if PROTOTYPE_ALLOWED
double meters_to_dlat(double dmeters, double lat)
#else
double meters_to_dlat(dmeters, lat)
double dmeters, lat;
#endif
{
   double rlat, m;

   rlat = lat * M_PI/180;
   m = 111132.09 - 566.05 * cos(2*rlat) + 1.2 * cos(4*rlat);
   return(dmeters / m);
}
