psConstants.h

Go to the documentation of this file.
00001 /* @file  psConstants.h
00002  *
00003  * @brief Definitions of various constants and common macros
00004  *
00005  * @author GLG, MHPCC
00006  *
00007  * @version $Revision: 1.95 $ $Name:  $
00008  * @date $Date: 2007/01/23 22:47:23 $
00009  *
00010  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00011  *
00012  * XXX: Add parenthesis around all arguments so that these macros can be
00013  *      called with complex expressions.
00014  *
00015  * XXX: All functions which use the PS_ASSERT macros must be scrutinized so
00016  * that we ensure that an argument which is expected to be output is
00017  * psFree'ed before reurning NULL.
00018  *
00019  * XXX: The macros have a name similar to PS_CHECK_CONDITION() and generally
00020  * throw a psError if the CONDITION is true.  However, some throw the error
00021  * if the CONDITION is false.  This should be consistant.
00022  *
00023  */
00024 
00025 #ifndef PS_CONSTANTS_H
00026 #define PS_CONSTANTS_H
00027 
00028 /// @addtogroup MathOps Mathematical Operations
00029 /// @{
00030 
00031 #include <math.h> // for M_PI
00032 
00033 /*****************************************************************************
00034 These are common mathimatical constants used by various functions in the psLib.
00035  *****************************************************************************/
00036 #ifndef M_PI
00037 #define M_PI   3.1415926535897932384626433832795029  /* pi */
00038 #define M_PI_2 1.5707963267948966192313216916397514  /* pi/2 */
00039 #define M_PI_4 0.7853981633974483096156608458198757  /* pi/4 */
00040 #define M_1_PI 0.3183098861837906715377675267450287  /* 1/pi */
00041 #define M_2_PI 0.6366197723675813430755350534900574  /* 2/pi */
00042 #endif // #ifndef M_PI
00043 
00044 #define DEG_TO_RAD(DEGREES) ((DEGREES) * M_PI / 180.0)
00045 #define MIN_TO_RAD(MINUTES) ((MINUTES) * M_PI / (180.0 * 60.0))
00046 #define SEC_TO_RAD(SECONDS) ((SECONDS) * M_PI / (180.0 * 60.0 * 60.0))
00047 #define RAD_TO_DEG(RADIANS) ((RADIANS) * 180.0 / M_PI)
00048 #define RAD_TO_MIN(RADIANS) ((RADIANS) * 180.0 * 60.0 / M_PI)
00049 #define RAD_TO_SEC(RADIANS) ((RADIANS) * 180.0 * 60.0 * 60.0 / M_PI)
00050 
00051 /*****************************************************************************
00052     Misc. macros:
00053 *****************************************************************************/
00054 #define PS_MAX(A, B) \
00055 (((A) > (B)) ? (A) : (B))
00056 
00057 #define PS_MIN(A, B) \
00058 (((A) < (B)) ? (A) : (B))
00059 
00060 #define PS_SQR(A) \
00061 ((A) * (A))
00062 
00063 #define PS_SWAP(X,Y) {double tmp=(X); (X) = (Y); (Y) = tmp;}
00064 
00065 // These defines for bitwise opertaions are necessary to yield results of the proper size (use instead of ~)
00066 #define PS_NOT_U8(A)(UCHAR_MAX-(A)) // Perform bitwise NOT on A which is of type U8
00067 #define PS_NOT_U16(A)(USHORT_MAX-(A)) // Perform bitwaise NOT on A which is of type U16
00068 
00069 /// @}
00070 #endif

Generated on Fri Feb 2 22:24:35 2007 for pslib by  doxygen 1.5.1