/**---------------------------------------------------------------------------
 ** 
 ** gficnv.h -- Header file for stand alone conversion macros
 ** 
 ** Author          : Pierre Jaccard
 ** Created On      : 1999/07/15 10:22:37
 ** Last Modified By: Pierre Jaccard
 ** Last Modified On: 1999/07/16 21:34:37
 ** Update Count    : 7
 ** Directory       : /home/pego/pcd1/codas3c/gfi/include/
 ** Version         : 0.0
 ** Status          : Unknown
 ** ---------------------------------------------------------------------- ** 
 ** DESCRIPTION: 
 ** 
 **    This file provides definitions and macros for conversion of data. These 
 **    are not defined elsewhere in libraries.
 ** 
 ** ---------------------------------------------------------------------- ** 
 ** REVISIONS: 
 ** ---------------------------------------------------------------------- ** 
 ** CHANGES: 
 **------------------------------------------------------------------------**/

#ifndef gficnv_already_included
#define gficnv_already_included

#include "common.h" /* M_PI */


/*
  Convert a longitude so that it ranges between -180 and +180 degrees.
*/
#define to180(x) (((x) > 180.0) ? \
									(((x)-((int)(x)/360)*360.0)-360.0) : \
									((x)-((int)(x)/360)*360.0))
/*
  Convert a longitude so that it ranges between 0 and 360 degrees.
*/
#define to360(x) (((x) < 0) ? \
									(((x)-((int)(x)/360)*360.0)+360.0) : \
									((x)-((int)(x)/360)*360.0))

/*
  Convert an angle from radians to degrees. This function is obsolete as it is 
  already defined in file dbext.h.
*/ 
#define to_deg(x) ((x)*180.0/M_PI)

/*
  Convert an angle from degrees to radians. This function is obsolete as it is 
  already defined in file dbext.h.
*/ 
#define to_rad(x) ((x)*M_PI/180.0)

/*
  Convert a number to an ULONG with the correspnding bit set to one
*/
#define to_bit(i) ((((i) >= 0) && ((i)<32)) ? ((0x1) << (i)) : (0))

#endif /* gficnv_already_included */
