#include <iostream>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
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 P_ONE_OVER_SIGMA_EXP (1.0f / 0.7975f) |
Referenced by pNRandf().
#define P_ONEOVERSQRT2PI (1.f / P_SQRT2PI) |
#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().
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().
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 }
static pVec pNRandVec | ( | float | stdev | ) | [inline, static] |
static pVec pRandVec | ( | ) | [inline, static] |
Definition at line 223 of file pVec.h.
References pRandf.
Referenced by PDSphere::Generate(), and PDBox::Generate().
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().
static bool pSameSignd | ( | const float & | a, | |
const float & | b | |||
) | [inline, static] |
Referenced by PDSphere::Generate().