Main Page   Namespace List   Alphabetical List   Data Structures   File List   Data Fields   Globals  

macros.h File Reference

Go to the source code of this file.

Defines

#define PI   3.14159265358979323846
 defines pi with 20 decimals

#define verbose   1
 prints debugging info to stdout

#define DEBUG   if (verbose) printf
#define GLERROR
#define AND   &&
#define OR   ||
#define NOT   !
#define MAX(a, b)   ((a)>(b) ? (a) : (b))
 MAX returns the greatest of two scalars.

#define MIN(a, b)   ((a)<(b) ? (a) : (b))
 MIN returns the smallest of two scalars.

#define IMAX(a, b)   ((a)>(b) ? (0) : (1))
 as MAX returns the greatest of two scalars, IMAX tells which one is greater

#define IMIN(a, b)   ((a)<(b) ? (0) : (1))
 as MIN returns the smallest of two scalars, IMIN tells which one is smaller

#define ABS(a)   ((a)>=0 ? (a) : (-(a)))
 absolute value of scalar

#define TEST_BIT(x, b)   (((x) & (1<<(b))) != 0 )
#define SET_BIT(x, b)   ((x) |= (1 << (b)))
#define CLEAR_BIT(x, b)   ((x) &= ~(1 << (b)))
#define TOGGLE_BIT(x, b)   ((TEST_BIT(x,b))?(CLEAR_BIT(x,b)):(SET_BIT(x,b)))
#define flushout   fflush(stdout)
 flushes the stdout output stream

#define flusherr   fflush(stderr)
 flushes the stderr output stream

#define randf()   ((float) rand() / (float)RAND_MAX )
#define SIGN(x)   ((x)>=0 ? 1 : -1)
 gets the sign of a number

#define DEG2RAD(x)   ((x)/180.0*pi)
 conversion from degrees to radians

#define RAD2DEG(x)   ((x)/pi*180.0)
 conversion from radians to degrees

#define CLAMP(x, lo, hi)   {if ((x) < (lo)) {(x)=(lo);} else if((x) > (hi)){(x)=(hi);}}
 clamps a value to some fixed interval


Define Documentation

#define ABS      ((a)>=0 ? (a) : (-(a)))
 

absolute value of scalar

#define AND   &&
 

#define CLAMP x,
lo,
hi       {if ((x) < (lo)) {(x)=(lo);} else if((x) > (hi)){(x)=(hi);}}
 

clamps a value to some fixed interval

#define CLEAR_BIT x,
     ((x) &= ~(1 << (b)))
 

#define DEBUG   if (verbose) printf
 

#define DEG2RAD      ((x)/180.0*pi)
 

conversion from degrees to radians

#define flusherr   fflush(stderr)
 

flushes the stderr output stream

#define flushout   fflush(stdout)
 

flushes the stdout output stream

#define GLERROR
 

Value:

{                                                              \
        GLenum code = glGetError();                                \
        while (code!=GL_NO_ERROR)                                  \
        {                                                          \
            printf("Gl error: %s\n",(char *) gluErrorString(code));\
                code = glGetError();                               \
        }                                                          \
    }
Checks for openGL error, if there is one, prints it on stdout Note: this routine is used for debugging

#define IMAX a,
     ((a)>(b) ? (0) : (1))
 

as MAX returns the greatest of two scalars, IMAX tells which one is greater

#define IMIN a,
     ((a)<(b) ? (0) : (1))
 

as MIN returns the smallest of two scalars, IMIN tells which one is smaller

#define MAX a,
     ((a)>(b) ? (a) : (b))
 

MAX returns the greatest of two scalars.

#define MIN a,
     ((a)<(b) ? (a) : (b))
 

MIN returns the smallest of two scalars.

#define NOT   !
 

#define OR   ||
 

#define PI   3.14159265358979323846
 

defines pi with 20 decimals

#define RAD2DEG      ((x)/pi*180.0)
 

conversion from radians to degrees

 
#define randf      ((float) rand() / (float)RAND_MAX )
 

floating-point random

Returns:
a random float between 0 and 1

#define SET_BIT x,
     ((x) |= (1 << (b)))
 

#define SIGN      ((x)>=0 ? 1 : -1)
 

gets the sign of a number

#define TEST_BIT x,
     (((x) & (1<<(b))) != 0 )
 

#define TOGGLE_BIT x,
     ((TEST_BIT(x,b))?(CLEAR_BIT(x,b)):(SET_BIT(x,b)))
 

#define verbose   1
 

prints debugging info to stdout


Generated on Wed Feb 18 16:32:52 2004 for POVAMA by doxygen1.2.18