macros.h File Reference

(r1785/r751)

#include <math.h>

Go to the source code of this file.

Defines

#define _Long(x)   ((INT32)(x))
#define _Int(x)   ((INT32)(x))
#define _Float(x)   ((FLOAT)(x))
#define _Dble(x)   ((double)(x))

Functions

INT32 LClamp (INT32 x, INT32 min, INT32 max)
INT32 LAbs (INT32 x)
INT32 LSign (INT32 x)
INT32 LSmooth (INT32 x)
INT32 LMin (INT32 x, INT32 y)
INT32 LMax (INT32 x, INT32 y)
INT32 LMin (INT32 x, INT32 y, INT32 z)
INT32 LMax (INT32 x, INT32 y, INT32 z)
float FClamp (float x)
float FAbs (float x)
float FFrac (float x)
float FCeil (float x)
float FFloor (float x)
float FRound (float x)
float FSign (float x)
float FSmooth (float x)
float FTrunc (float x)
float FMin (float x, float y)
float FMax (float x, float y)
float FMax (float x, float y, float z)
float FMin (float x, float y, float z)
double DAbs (double f)
double DFrac (double f)
double DCeil (double f)
double DCube (double f)
double DDegrees (double f)
double DFloor (double f)
double DInv (double f)
BOOL DIsZero (double f)
double DRadians (double f)
double DRound (double f)
double DSign (double f)
double DSmooth (double f)
double DTrunc (double f)
double DZSign (double f)
double DCubeRoot (double x)
BOOL DFuzEQ (double f, double g)
BOOL DFuzGEQ (double f, double g)
BOOL DFuzLEQ (double f, double g)
double DMax (double f, double g)
double DMin (double f, double g)
void DSwap (double &f, double &g)
void DSwap (INT32 &i, INT32 &j)
void DSort (double &lo, double &hi)
double DStep (double a, double f)
double DFuzStep (double a, double f, double fzz)
double DGamma (double gamma, double f)
double DBias (double bias, double f)
double DGain (double gain, double f)
double DExculsiveOr (double a, double b)
double DIntersection (double a, double b)
double DDifference (double a, double b)
double DRepeat (double u, double freq)
double DTile (double u, double freq)
double DClamp (const double x, const double a, const double b)
double DLerp (double f, double l, double h)
double DNorm (double f, double a, double b)
double DMax (double f, double g, double h)
double DMin (double f, double g, double h)
double DSlide (double f, double l, double h)
double DSmoothStep (double a, double b, double f)
double DBoxStep (double a, double b, double x)
double DPulse (double a, double b, double x)
double DFuzPulse (double a, double b, double x, double fzz)
double DRange (double t, double min, double max, double lo, double mid, double hi)

Variables

double const XS_2PI = 6.28318530717958623200
double const XS_DEGTORAD = 0.01745329251994329547
double const XS_E = 2.71828182845904553488
double const XS_EEXPPI = 23.14069263277927390732
double const XS_GOLDEN = 1.61803398874989490253
double const XS_INVPI = 0.31830988618379069122
double const XS_LN10 = 2.30258509299404590109
double const XS_LN2 = 0.69314718055994528623
double const XS_LOG10E = 0.43429448190325187218
double const XS_LOG2E = 1.44269504088896338700
double const XS_LOG05 = -0.693147180559945
double const XS_PI = 3.14159265358979323846
double const XS_PIDIV2 = 1.57079632679489655800
double const XS_PIDIV4 = 0.78539816339744827900
double const XS_RADTODEG = 57.29577951308232286465
double const XS_SQRT2 = 1.41421356237309514547
double const XS_SQRT2PI = 2.50662827463100024161
double const XS_SQRT3 = 1.73205080756887719318
double const XS_SQRT10 = 3.16227766016837952279
double const XS_SQRTE = 1.64872127070012819416
double const XS_SQRTHALF = 0.70710678118654757274
double const XS_SQRTLN2 = 0.83255461115769768821
double const XS_SQRTPI = 1.77245385090551588192
double const XS_EPSILON = 1.0e-10
double const XS_GOOGOL = 1.0e50


Define Documentation

#define _Dble  )     ((double)(x))
 

Definition at line 113 of file macros.h.

#define _Float  )     ((FLOAT)(x))
 

Definition at line 112 of file macros.h.

#define _Int  )     ((INT32)(x))
 

Definition at line 111 of file macros.h.

#define _Long  )     ((INT32)(x))
 

Definition at line 110 of file macros.h.


Function Documentation

double DAbs double  f  )  [inline]
 

Definition at line 288 of file macros.h.

00289 {
00290     return (f >= 0) ? f : -f;
00291 }

double DBias double  bias,
double  f
[inline]
 

Definition at line 424 of file macros.h.

00425 {
00426     return pow(f,log(bias)/log(0.5));
00427 }

double DBoxStep double  a,
double  b,
double  x
[inline]
 

Definition at line 502 of file macros.h.

00503 {
00504     return (DClamp((x-a)/(b-a),0,1));
00505 }

double DCeil double  f  )  [inline]
 

Definition at line 298 of file macros.h.

00299 {
00300     return (f == _Int(f)) ? f : (f > 0) ? _Dble(_Int(f) + 1) : _Dble(_Int(f));
00301 }

double DClamp const double  x,
const double  a,
const double  b
[inline]
 

Definition at line 467 of file macros.h.

00468 {
00469     return (x < a ? a : (x > b ? b : x));
00470 }

double DCube double  f  )  [inline]
 

Definition at line 303 of file macros.h.

00304 {
00305     return f * f * f;
00306 }

double DCubeRoot double  x  )  [inline]
 

Definition at line 358 of file macros.h.

00359 {
00360     return (x>0.0) ? pow(x, 1.0/3.0) : (x<0.0) ? -pow(-x, 1.0/3.0) : 0.0;
00361 }

double DDegrees double  f  )  [inline]
 

Definition at line 308 of file macros.h.

00309 {
00310     return f * XS_RADTODEG;
00311 }

double DDifference double  a,
double  b
[inline]
 

Definition at line 444 of file macros.h.

00445 {
00446     return (a - a * b);
00447 }

double DExculsiveOr double  a,
double  b
[inline]
 

Definition at line 434 of file macros.h.

00435 {
00436     return (a + b - a * b);
00437 }

double DFloor double  f  )  [inline]
 

Definition at line 313 of file macros.h.

00314 {
00315     return (f == _Int(f)) ? f : (f > 0) ? _Dble(_Int(f)) : _Dble(_Int(f)-1);
00316 }

double DFrac double  f  )  [inline]
 

Definition at line 293 of file macros.h.

00294 {
00295     return (f-_Long(f));
00296 }

BOOL DFuzEQ double  f,
double  g
[inline]
 

Definition at line 369 of file macros.h.

00370 {
00371     return (f <= g) ? (f >= g - XS_EPSILON) : (f <= g + XS_EPSILON);
00372 }

BOOL DFuzGEQ double  f,
double  g
[inline]
 

Definition at line 374 of file macros.h.

00375 {
00376     return (f >= g - XS_EPSILON);
00377 }

BOOL DFuzLEQ double  f,
double  g
[inline]
 

Definition at line 379 of file macros.h.

00380 {
00381     return (f <= g + XS_EPSILON);
00382 }

double DFuzPulse double  a,
double  b,
double  x,
double  fzz
[inline]
 

Definition at line 512 of file macros.h.

00513 {
00514     return (DFuzStep(a,x,-fzz) - DFuzStep(b,x,+fzz));
00515 }

double DFuzStep double  a,
double  f,
double  fzz
[inline]
 

Definition at line 414 of file macros.h.

00415 {
00416     return _Dble(f>=(a+fzz));
00417 }

double DGain double  gain,
double  f
[inline]
 

Definition at line 429 of file macros.h.

00430 {
00431     return (f<0.5) ? (DBias(1.0-gain,2.0*f)/2.0) : (1-DBias(1.0-gain, 2.0-2.0*f)/2.0);
00432 }

double DGamma double  gamma,
double  f
[inline]
 

Definition at line 419 of file macros.h.

00420 {
00421     return (gamma==0.0) ? XS_GOOGOL : pow(f, 1/gamma);
00422 }

double DIntersection double  a,
double  b
[inline]
 

Definition at line 439 of file macros.h.

00440 {
00441     return (a * b);
00442 }

double DInv double  f  )  [inline]
 

Definition at line 318 of file macros.h.

00319 {
00320     return 1.0 / f;
00321 }

BOOL DIsZero double  f  )  [inline]
 

Definition at line 323 of file macros.h.

00324 {
00325     return ((f<=0.0) ? (f >= -XS_EPSILON) : (f <= XS_EPSILON));
00326 }

double DLerp double  f,
double  l,
double  h
[inline]
 

Definition at line 472 of file macros.h.

00473 {
00474     return l + ((h - l) * f );
00475 }

double DMax double  f,
double  g,
double  h
[inline]
 

Definition at line 482 of file macros.h.

00483 {
00484     return (f > g) ? DMax(f, h) : DMax(g, h);
00485 }

double DMax double  f,
double  g
[inline]
 

Definition at line 384 of file macros.h.

00385 {
00386     return (f > g) ? f : g;
00387 }

double DMin double  f,
double  g,
double  h
[inline]
 

Definition at line 487 of file macros.h.

00488 {
00489     return (f < g) ? DMin(f, h) : DMin(g, h);
00490 }

double DMin double  f,
double  g
[inline]
 

Definition at line 389 of file macros.h.

00390 {
00391     return (f < g) ? f : g;
00392 }

double DNorm double  f,
double  a,
double  b
[inline]
 

Definition at line 477 of file macros.h.

00478 {
00479     return (f-a)/(b-a);
00480 }

double DPulse double  a,
double  b,
double  x
[inline]
 

Definition at line 507 of file macros.h.

00508 {
00509     return (DStep(a,x) - DStep(b,x));
00510 }

double DRadians double  f  )  [inline]
 

Definition at line 328 of file macros.h.

00329 {
00330     return f * XS_DEGTORAD;
00331 }

double DRange double  t,
double  min,
double  max,
double  lo,
double  mid,
double  hi
[inline]
 

Definition at line 517 of file macros.h.

00520 {
00521     return (t<min) ? lo : ((t>max) ? hi : mid);
00522 }

double DRepeat double  u,
double  freq
[inline]
 

Definition at line 449 of file macros.h.

00450 {
00451     // return distance into tile
00452     return DFrac(u*freq);
00453 }

double DRound double  f  )  [inline]
 

Definition at line 333 of file macros.h.

00334 {
00335     return (f >= 0) ? _Dble(_Int(f + 0.5)) : _Dble(- _Int(0.5 - f));
00336 }

double DSign double  f  )  [inline]
 

Definition at line 338 of file macros.h.

00339 {
00340     return (f < 0) ? -1.0 : 1.0;
00341 }

double DSlide double  f,
double  l,
double  h
[inline]
 

Definition at line 492 of file macros.h.

00493 {
00494     return (f < 0) ? l : (f > 1) ? h : DLerp(DSmooth(f), l, h);
00495 }

double DSmooth double  f  )  [inline]
 

Definition at line 343 of file macros.h.

00344 {
00345     return (3.0 - 2.0 * f) * f * f;
00346 }

double DSmoothStep double  a,
double  b,
double  f
[inline]
 

Definition at line 497 of file macros.h.

00498 {
00499     return (f < a) ? 0.0 : (f > b) ? 1.0 : DSmooth(DNorm(f,a,b));
00500 }

void DSort double &  lo,
double &  hi
[inline]
 

Definition at line 404 of file macros.h.

00405 {
00406     if (lo>hi) DSwap(lo,hi);
00407 }

double DStep double  a,
double  f
[inline]
 

Definition at line 409 of file macros.h.

00410 {
00411     return _Dble(f>=a);
00412 }

void DSwap INT32 &  i,
INT32 &  j
[inline]
 

Definition at line 399 of file macros.h.

00400 {
00401     INT32 gmTmp = i; i = j; j = gmTmp;
00402 }

void DSwap double &  f,
double &  g
[inline]
 

Definition at line 394 of file macros.h.

00395 {
00396     double gmTmp = f; f = g; g = gmTmp;
00397 }

double DTile double  u,
double  freq
[inline]
 

Definition at line 455 of file macros.h.

00456 {
00457     // return the tile number
00458     return _Long(u*freq);
00459 }

double DTrunc double  f  )  [inline]
 

Definition at line 348 of file macros.h.

00349 {
00350     return _Dble(_Int(f));
00351 }

double DZSign double  f  )  [inline]
 

Definition at line 353 of file macros.h.

00354 {
00355     return (f > 0) ? 1.0 : (f < 0) ? -1.0 : 0.0;
00356 }

float FAbs float  x  )  [inline]
 

Definition at line 207 of file macros.h.

00208 {
00209     return (x >= 0.0f) ? x : -x;
00210 }

float FCeil float  x  )  [inline]
 

Definition at line 217 of file macros.h.

00218 {
00219     return (x == _Int(x)) ? x : (x > 0.0f) ? _Float(_Int(x) + 1.0f) : _Float(_Int(x));
00220 }

float FClamp float  x  )  [inline]
 

Definition at line 202 of file macros.h.

00203 {
00204     return (x < 0.0f ? 0.0f : (x > 1.0f ? 1.0f : x));
00205 }

float FFloor float  x  )  [inline]
 

Definition at line 222 of file macros.h.

00223 {
00224     return (x == _Int(x)) ? x : (x > 0.0f) ? _Float(_Int(x)) : _Float(_Int(x) - 1.0f);
00225 }

float FFrac float  x  )  [inline]
 

Definition at line 212 of file macros.h.

00213 {
00214     return (x-((INT32)(x)));
00215 }

float FMax float  x,
float  y,
float  z
[inline]
 

Definition at line 267 of file macros.h.

00268 {
00269     return (x > y) ? FMax(x, z) : FMax(y, z);
00270 }

float FMax float  x,
float  y
[inline]
 

Definition at line 257 of file macros.h.

00258 {
00259     return (x > y) ? x : y;
00260 }

float FMin float  x,
float  y,
float  z
[inline]
 

Definition at line 272 of file macros.h.

00273 {
00274     return (x < y) ? FMin(x, z) : FMin(y, z);
00275 }

float FMin float  x,
float  y
[inline]
 

Definition at line 252 of file macros.h.

00253 {
00254     return (x < y) ? x : y;
00255 }

float FRound float  x  )  [inline]
 

Definition at line 227 of file macros.h.

00228 {
00229     return (x >= 0.0f) ? _Float(_Int(x + 0.5f)) : _Float(- _Int(0.5f - x));
00230 }

float FSign float  x  )  [inline]
 

Definition at line 232 of file macros.h.

00233 {
00234     return (x < 0.0f) ? -1.0f : 1.0f;
00235 }

float FSmooth float  x  )  [inline]
 

Definition at line 237 of file macros.h.

00238 {
00239     return (3.0f - 2.0f * x) * x * x;
00240 }

float FTrunc float  x  )  [inline]
 

Definition at line 242 of file macros.h.

00243 {
00244     return _Float(_Int(x));
00245 }

INT32 LAbs INT32  x  )  [inline]
 

Definition at line 151 of file macros.h.

00152 {
00153     return (x >= 0) ? x : -x;
00154 }

INT32 LClamp INT32  x,
INT32  min,
INT32  max
[inline]
 

Definition at line 146 of file macros.h.

00147 {
00148     return (x < min ? min : (x > max ? max : x));
00149 }

INT32 LMax INT32  x,
INT32  y,
INT32  z
[inline]
 

Definition at line 191 of file macros.h.

00192 {
00193     return (x > y) ? LMax(x, z) : LMax(y, z);
00194 }

INT32 LMax INT32  x,
INT32  y
[inline]
 

Definition at line 176 of file macros.h.

00177 {
00178     return (x > y) ? x : y;
00179 }

INT32 LMin INT32  x,
INT32  y,
INT32  z
[inline]
 

Definition at line 186 of file macros.h.

00187 {
00188     return (x < y) ? LMin(x, z) : LMin(y, z);
00189 }

INT32 LMin INT32  x,
INT32  y
[inline]
 

Definition at line 171 of file macros.h.

00172 {
00173     return (x < y) ? x : y;
00174 }

INT32 LSign INT32  x  )  [inline]
 

Definition at line 156 of file macros.h.

00157 {
00158     return (x < 0) ? -1 : 1;
00159 }

INT32 LSmooth INT32  x  )  [inline]
 

Definition at line 161 of file macros.h.

00162 {
00163     return (3 - 2 * x) * x * x;
00164 }


Variable Documentation

double const XS_2PI = 6.28318530717958623200
 

Definition at line 115 of file macros.h.

double const XS_DEGTORAD = 0.01745329251994329547
 

Definition at line 116 of file macros.h.

double const XS_E = 2.71828182845904553488
 

Definition at line 117 of file macros.h.

double const XS_EEXPPI = 23.14069263277927390732
 

Definition at line 118 of file macros.h.

double const XS_EPSILON = 1.0e-10
 

Definition at line 138 of file macros.h.

double const XS_GOLDEN = 1.61803398874989490253
 

Definition at line 119 of file macros.h.

double const XS_GOOGOL = 1.0e50
 

Definition at line 139 of file macros.h.

double const XS_INVPI = 0.31830988618379069122
 

Definition at line 120 of file macros.h.

double const XS_LN10 = 2.30258509299404590109
 

Definition at line 121 of file macros.h.

double const XS_LN2 = 0.69314718055994528623
 

Definition at line 122 of file macros.h.

double const XS_LOG05 = -0.693147180559945
 

Definition at line 125 of file macros.h.

double const XS_LOG10E = 0.43429448190325187218
 

Definition at line 123 of file macros.h.

double const XS_LOG2E = 1.44269504088896338700
 

Definition at line 124 of file macros.h.

double const XS_PI = 3.14159265358979323846
 

Definition at line 126 of file macros.h.

double const XS_PIDIV2 = 1.57079632679489655800
 

Definition at line 127 of file macros.h.

double const XS_PIDIV4 = 0.78539816339744827900
 

Definition at line 128 of file macros.h.

double const XS_RADTODEG = 57.29577951308232286465
 

Definition at line 129 of file macros.h.

double const XS_SQRT10 = 3.16227766016837952279
 

Definition at line 133 of file macros.h.

double const XS_SQRT2 = 1.41421356237309514547
 

Definition at line 130 of file macros.h.

double const XS_SQRT2PI = 2.50662827463100024161
 

Definition at line 131 of file macros.h.

double const XS_SQRT3 = 1.73205080756887719318
 

Definition at line 132 of file macros.h.

double const XS_SQRTE = 1.64872127070012819416
 

Definition at line 134 of file macros.h.

double const XS_SQRTHALF = 0.70710678118654757274
 

Definition at line 135 of file macros.h.

double const XS_SQRTLN2 = 0.83255461115769768821
 

Definition at line 136 of file macros.h.

double const XS_SQRTPI = 1.77245385090551588192
 

Definition at line 137 of file macros.h.


Generated on Sat Nov 10 03:49:12 2007 for Camelot by  doxygen 1.4.4