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

   POS_TO_M.C

   Routines for converting latitude and longitude differences
   into meters.  They use the first few terms in the approximations
   given in: 

   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 dlon_to_meters(double dlon, double lat)
#else
double dlon_to_meters(dlon, lat)
double dlon, lat;
#endif
{
   double rlat, p;

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

#if PROTOTYPE_ALLOWED
double dlat_to_meters(double dlat, double lat)
#else
double dlat_to_meters(dlat, lat)
double dlat, lat;
#endif
{
   double rlat, m;

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