/cygdrive/d/src/svn/vrut/trunk/core/src/common.h File Reference

#include "3dmath.h"
#include <wx/string.h>

Go to the source code of this file.

Defines

#define DLLIMPORT   __attribute__ ((visibility("default")))
#define DLLEXPORT
#define __max(a, b)   (((a) > (b)) ? (a) : (b))
#define __min(a, b)   (((a) < (b)) ? (a) : (b))
#define _strnicmp   strncasecmp
#define _isnan   isnan
#define SAFE_DELETE(a)
#define SAFE_DELETE_ARR(a)
#define SAFE_DELETE_ARR_EACH(a, cnt)
#define SAFE_RELEASE(a)
#define VECTOR3_XAXIS   VECTOR3(1,0,0)
#define VECTOR3_YAXIS   VECTOR3(0,1,0)
#define VECTOR3_ZAXIS   VECTOR3(0,0,1)
#define ABS   absolute
 Absolute value.

Typedefs

typedef vector2 VECTOR2
typedef vector3 VECTOR3
typedef vector4 VECTOR4
typedef matrix MATRIX
typedef plane PLANE

Functions

wxString CloneWxString (const wxString &str)
 Clone wxString.
bool isTrue (const wxString &val)
 Check if given string is one of defined true values.
int roundVR (float x)
 Round float number.
int roundVR (double x)
 Round double number.
template<typename T>
absolute (T x)
 Absolute value.
int random (int min, int max)
 Random generator with limits (included).
float random (float min, float max)
 Random generator with limits (included).
double random (double min, double max)
 Random generator with limits (included).

Variables

const float EPSILON = 1e-5f
 Smallest distinguishable value.
const float DEG2RAD = 0.017453293f
 Degrees to radians coeficient.
const float RAD2DEG = 57.29577951f
 Radians to degrees coeficient.
const float MAX_FLOAT = 3.40282347e37F
 Maximal float.
const float MIN_FLOAT = -3.40282347e37F
 Minimal float.
const wxString TRUE_STRINGS [] = { wxT("true"), wxT("enable"), wxT("enabled"), wxT("on"), wxT("yes"), wxT("1") }
 Allowed true values.
const size_t TRUE_STRINGS_COUNT = 6
const unsigned GL_ID_NONE = (unsigned)~(unsigned(0))


Define Documentation

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

Definition at line 58 of file common.h.

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

Definition at line 59 of file common.h.

#define _isnan   isnan

Definition at line 61 of file common.h.

#define _strnicmp   strncasecmp

Definition at line 60 of file common.h.

#define ABS   absolute

Absolute value.

Definition at line 127 of file common.h.

#define DLLEXPORT

Definition at line 57 of file common.h.

#define DLLIMPORT   __attribute__ ((visibility("default")))

Definition at line 56 of file common.h.

#define SAFE_DELETE (  ) 

Value:

{if (a)\
              delete (a);\
       (a) = NULL;}

Definition at line 64 of file common.h.

#define SAFE_DELETE_ARR (  ) 

Value:

{if (a)\
              delete [] (a);\
       (a) = NULL;}

Definition at line 69 of file common.h.

#define SAFE_DELETE_ARR_EACH ( a,
cnt   ) 

Value:

for (unsigned _xx_ = 0; _xx_ < (cnt); _xx_++)\
              SAFE_DELETE((a)[_xx_])

Definition at line 74 of file common.h.

#define SAFE_RELEASE (  ) 

Value:

{if (a)\
              (a)->Release();}

Definition at line 78 of file common.h.

#define VECTOR3_XAXIS   VECTOR3(1,0,0)

Definition at line 93 of file common.h.

#define VECTOR3_YAXIS   VECTOR3(0,1,0)

Definition at line 94 of file common.h.

#define VECTOR3_ZAXIS   VECTOR3(0,0,1)

Definition at line 95 of file common.h.


Typedef Documentation

typedef matrix MATRIX

Definition at line 90 of file common.h.

typedef plane PLANE

Definition at line 91 of file common.h.

typedef vector2 VECTOR2

Definition at line 87 of file common.h.

typedef vector3 VECTOR3

Definition at line 88 of file common.h.

typedef vector4 VECTOR4

Definition at line 89 of file common.h.


Function Documentation

template<typename T>
T absolute ( x  )  [inline]

Absolute value.

Definition at line 131 of file common.h.

00132 {
00133        return ( x >= 0 ? x : -x );
00134 }

wxString CloneWxString ( const wxString &  str  )  [inline]

Clone wxString.

Definition at line 99 of file common.h.

00100 {
00101        wxString cloned;
00102        return cloned.append(str);
00103 }

bool isTrue ( const wxString &  val  )  [inline]

Check if given string is one of defined true values.

Definition at line 106 of file common.h.

00107 {
00108        for (size_t i = 0; i < TRUE_STRINGS_COUNT; i++)
00109               if (val.IsSameAs(TRUE_STRINGS[i], false))
00110                      return true;
00111        return false;
00112 }

double random ( double  min,
double  max 
) [inline]

Random generator with limits (included).

Definition at line 149 of file common.h.

00150 {
00151        return double(rand())/RAND_MAX * (max - min) + min;
00152 }

float random ( float  min,
float  max 
) [inline]

Random generator with limits (included).

Definition at line 143 of file common.h.

00144 {
00145        return float(rand())/RAND_MAX * (max - min) + min;
00146 }

int random ( int  min,
int  max 
) [inline]

Random generator with limits (included).

Definition at line 137 of file common.h.

00138 {
00139        return rand()%(max-min+1) + min;
00140 }

int roundVR ( double  x  )  [inline]

Round double number.

Definition at line 121 of file common.h.

00122 {
00123        return int(x > 0.0 ? x + 0.5 : x - 0.5);
00124 }

int roundVR ( float  x  )  [inline]

Round float number.

Definition at line 115 of file common.h.

00116 {
00117        return int(x > 0.0f ? x + 0.5f : x - 0.5f);
00118 }


Variable Documentation

const float DEG2RAD = 0.017453293f

Degrees to radians coeficient.

Definition at line 22 of file common.h.

const float EPSILON = 1e-5f

Smallest distinguishable value.

Definition at line 20 of file common.h.

const unsigned GL_ID_NONE = (unsigned)~(unsigned(0))

Definition at line 85 of file common.h.

const float MAX_FLOAT = 3.40282347e37F

Maximal float.

Definition at line 27 of file common.h.

const float MIN_FLOAT = -3.40282347e37F

Minimal float.

Definition at line 29 of file common.h.

const float RAD2DEG = 57.29577951f

Radians to degrees coeficient.

Definition at line 24 of file common.h.

const wxString TRUE_STRINGS[] = { wxT("true"), wxT("enable"), wxT("enabled"), wxT("on"), wxT("yes"), wxT("1") }

Allowed true values.

Definition at line 83 of file common.h.

const size_t TRUE_STRINGS_COUNT = 6

Definition at line 84 of file common.h.


Generated on Tue Mar 10 14:41:35 2009 for VRUT by  doxygen 1.5.5