Main Page | Class List | File List

MathsStruct.h

00001 /*      Structures definitions
00002 
00003 */
00004 
00005 #ifndef __MATHSSTRUCT_H_
00006 #define __MATHSSTRUCT_H_
00007 
00009 
00010 const float PI       =  3.14159265358979323846f;                // Pi
00011 
00012 #define DEGTORAD(x)     ( ((x) * PI) / 180.0 )
00013 #define RADTODEG(x)     ( ((x) * 180.0) / PI )
00014 
00015 #define SQR(x)          ( (x) * (x) )
00016 
00017 // limits a value to low and high
00018 #define LIMIT_RANGE(low, value, high)   {       if (value < low)        value = low;    else if(value > high)   value = high;   }
00019 
00020 __forceinline void SWAP(float &x, float &y) {   float temp;     temp = x;       x = y;  y = temp;       }
00021 
00023 
00024 // Floating Point Library Specific
00025 
00026 const float     EPSILON                                         = 0.005f;               // error tolerance for check
00027 const int       FLOAT_DECIMAL_TOLERANCE         = 3;                    // decimal places for float rounding
00028 
00029 #define ZERO_CLAMP(x)   ( (EPSILON > fabs(x))?0.0f:(x) )                                                // set float to 0 if within tolerance
00030 
00031 #define FLOAT_EQ(x,v)   ( ((v) - EPSILON) < (x) && (x) < ((v) + EPSILON) )              // float equality test
00032 
00034 
00035 __forceinline float ROUND(const float value, const int accuracy)                // round a float to a specified degree of accuracy
00036 {
00037         double integer, fraction;
00038 
00039         fraction = modf(value, &integer);               // get fraction and int components
00040 
00041         return(float(integer + (float(int(fraction*pow(10,accuracy)))) / pow(10, accuracy) ) );
00042 }       // end float ROUND
00043 
00044 
00046 
00047 #endif  // __MATHSSTRUCT_H_

Generated on Mon Jan 26 22:13:13 2004 for fluid3 by doxygen 1.3.5