src/thirdparty/particles/pVec.h File Reference

#include <iostream>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>

Include dependency graph for pVec.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  pVec

Defines

#define M_PI   3.1415926535897932384626433f
#define P_ONEOVER_RAND_MAX   (1.0f/((float) RAND_MAX))
#define pRandf()   (((float) rand())*P_ONEOVER_RAND_MAX)
#define pSRandf(x)   srand(x)
#define P_SQRT2PI   2.506628274631000502415765284811045253006f
#define P_ONEOVERSQRT2PI   (1.f / P_SQRT2PI)
#define P_ONE_OVER_SIGMA_EXP   (1.0f / 0.7975f)

Functions

static float fsqr (float f)
static bool pSameSign (const float &a, const float &b)
static bool pSameSignd (const float &a, const float &b)
static float pNRandf (float sigma=1.0f)
static pVec pRandVec ()
static pVec pNRandVec (float stdev)

Variables

static pVec vHalf (0.5, 0.5, 0.5)


Define Documentation

#define M_PI   3.1415926535897932384626433f

Definition at line 19 of file pVec.h.

#define P_ONE_OVER_SIGMA_EXP   (1.0f / 0.7975f)

Referenced by pNRandf().

#define P_ONEOVER_RAND_MAX   (1.0f/((float) RAND_MAX))

Definition at line 27 of file pVec.h.

#define P_ONEOVERSQRT2PI   (1.f / P_SQRT2PI)

Definition at line 33 of file pVec.h.

Referenced by PDBlob::PDBlob().

#define P_SQRT2PI   2.506628274631000502415765284811045253006f

Definition at line 32 of file pVec.h.

 
#define pRandf (  )     (((float) rand())*P_ONEOVER_RAND_MAX)

Definition at line 28 of file pVec.h.

Referenced by PDDisc::Generate(), PDSphere::Generate(), PDCone::Generate(), PDCylinder::Generate(), PDRectangle::Generate(), PDTriangle::Generate(), PDLine::Generate(), pNRandf(), pRandVec(), and PDBlob::Within().

#define pSRandf ( x   )     srand(x)

Definition at line 29 of file pVec.h.

Referenced by pSeed().


Function Documentation

static float fsqr ( float  f  )  [inline, static]

Definition at line 40 of file pVec.h.

Referenced by PAAvoid::Exec(), PDSphere::Generate(), pBounce(), pDamping(), PDBlob::PDBlob(), PDCone::PDCone(), PDCylinder::PDCylinder(), PDDisc::PDDisc(), PDSphere::PDSphere(), pNRandf(), pRotDamping(), and PDCone::Within().

00040 { return f * f; }

Here is the caller graph for this function:

static float pNRandf ( float  sigma = 1.0f  )  [inline, static]

Definition at line 51 of file pVec.h.

References expf(), fsqr(), logf(), P_ONE_OVER_SIGMA_EXP, and pRandf.

Referenced by pNRandVec().

00052 {
00053 #define P_ONE_OVER_SIGMA_EXP (1.0f / 0.7975f)
00054 
00055     if(sigma == 0) return 0;
00056 
00057     float y;
00058     do {
00059         y = -logf(pRandf());
00060     }
00061     while(pRandf() > expf(-fsqr(y - 1.0f)*0.5f));
00062 
00063     if(rand() & 0x1)
00064         return y * sigma * P_ONE_OVER_SIGMA_EXP;
00065     else
00066         return -y * sigma * P_ONE_OVER_SIGMA_EXP;
00067 }

Here is the call graph for this function:

Here is the caller graph for this function:

static pVec pNRandVec ( float  stdev  )  [inline, static]

Definition at line 228 of file pVec.h.

References pNRandf().

Referenced by PDBlob::Generate().

00229 {
00230     return pVec(pNRandf(stdev), pNRandf(stdev), pNRandf(stdev));
00231 }

Here is the call graph for this function:

Here is the caller graph for this function:

static pVec pRandVec (  )  [inline, static]

Definition at line 223 of file pVec.h.

References pRandf.

Referenced by PDSphere::Generate(), and PDBox::Generate().

00224 {
00225     return pVec(pRandf(), pRandf(), pRandf());
00226 }

Here is the caller graph for this function:

static bool pSameSign ( const float &  a,
const float &  b 
) [inline, static]

Definition at line 42 of file pVec.h.

Referenced by PABounce::Exec(), and PAAvoid::Exec().

00042 { return a * b >= 0.0f; }

Here is the caller graph for this function:

static bool pSameSignd ( const float &  a,
const float &  b 
) [inline, static]

Definition at line 43 of file pVec.h.

00044 {
00045     const int *fi = reinterpret_cast<const int *>(&a);
00046     const int *gi = reinterpret_cast<const int *>(&b);
00047     return !(((*fi) ^ (*gi)) & 0x80000000);
00048 }


Variable Documentation

pVec vHalf(0.5, 0.5, 0.5) [static]

Referenced by PDSphere::Generate().


Generated on Sat Mar 15 23:10:27 2008 for Armagetron Advanced by  doxygen 1.5.4