AI_Math.h File Reference
#include <math.h>
#include <stdlib.h>
Go to the source code of this file.
Defines | |
#define | PI (3.1415926535897932384626433832795028841971693993751f) |
#define | AI_PI PI |
#define | AI_2PI 6.2831853f |
#define | AI_HALFPI 1.570796326f |
#define | AI_QUARTERPI 0.785398163f |
#define | AI_TINY 0.00001f |
#define | AI_INFINITY 3500000.0f |
#define | AI_SQRT2 1.414213562373f |
#define | ai_max(a, b) (((a) > (b)) ? (a) : (b)) |
#define | ai_min(a, b) (((a) < (b)) ? (a) : (b)) |
#define | ai_abs(a) (((a)<0.0f) ? (-(a)) : (a)) |
#define | ai_sgn(a) (((a)<0.0f) ? (-1) : (1)) |
#define | ai_deg2rad(d) (((d)*AI_PI)/180.0f) |
#define | ai_rad2deg(r) (((r)*180.0f)/AI_PI) |
#define | ai_sin(x) (float(sin(x))) |
#define | ai_cos(x) (float(cos(x))) |
#define | ai_tan(x) (float(tan(x))) |
#define | ai_atan(x) (float(atan(x))) |
Functions | |
static float | ai_log2 (float f) |
static int | ai_iclamp (int val, int minVal, int maxVal) |
static float | ai_acos (float x) |
static float | ai_asin (float x) |
static float | ai_sqrt (float x) |
static bool | ai_fequal (float f0, float f1, float tol) |
static bool | ai_fless (float f0, float f1, float tol) |
static bool | ai_fgreater (float f0, float f1, float tol) |
static long | ai_ftol (float val) |
static float | ai_smooth (float newVal, float curVal, float maxChange) |
static float | ai_clamp (float val, float lower, float upper) |
static float | ai_saturate (float val) |
static float | ai_rand () |
static int | ai_fchop (float f) |
static int | ai_frnd (float f) |
static float | ai_lerp (float x, float y, float l) |
static bool | ai_isEqualFloat (const float f0, const float f1, const float tol) |
static int | ai_random (const int i_sides) |
template<class TYPE> | |
static void | ai_lerp (TYPE &result, const TYPE &val0, const TYPE &val1, float lerpVal) |
template<> | |
static void | ai_lerp< int > (int &result, const int &val0, const int &val1, float lerpVal) |
template<> | |
static void | ai_lerp< float > (float &result, const float &val0, const float &val1, float lerpVal) |
Variables | |
const float | AI_LN_2 = 0.693147180559945f |
Define Documentation
#define AI_2PI 6.2831853f |
#define ai_abs | ( | a | ) | (((a)<0.0f) ? (-(a)) : (a)) |
#define ai_atan | ( | x | ) | (float(atan(x))) |
#define ai_cos | ( | x | ) | (float(cos(x))) |
#define ai_deg2rad | ( | d | ) | (((d)*AI_PI)/180.0f) |
#define AI_HALFPI 1.570796326f |
#define AI_INFINITY 3500000.0f |
#define ai_max | ( | a, | |||
b | ) | (((a) > (b)) ? (a) : (b)) |
#define ai_min | ( | a, | |||
b | ) | (((a) < (b)) ? (a) : (b)) |
#define AI_PI PI |
#define AI_QUARTERPI 0.785398163f |
#define ai_rad2deg | ( | r | ) | (((r)*180.0f)/AI_PI) |
#define ai_sgn | ( | a | ) | (((a)<0.0f) ? (-1) : (1)) |
#define ai_sin | ( | x | ) | (float(sin(x))) |
#define AI_SQRT2 1.414213562373f |
#define ai_tan | ( | x | ) | (float(tan(x))) |
#define AI_TINY 0.00001f |
#define PI (3.1415926535897932384626433832795028841971693993751f) |
General math functions and macros.
(C) 2003 RadonLabs GmbH
Function Documentation
static float ai_acos | ( | float | x | ) | [inline, static] |
acos with value clamping.
static float ai_asin | ( | float | x | ) | [inline, static] |
asin with value clamping.
static float ai_clamp | ( | float | val, | |
float | lower, | |||
float | upper | |||
) | [inline, static] |
Clamp a value against lower und upper boundary.
static int ai_fchop | ( | float | f | ) | [inline, static] |
Chop float to int.
static bool ai_fequal | ( | float | f0, | |
float | f1, | |||
float | tol | |||
) | [inline, static] |
A fuzzy floating point equality check
static bool ai_fgreater | ( | float | f0, | |
float | f1, | |||
float | tol | |||
) | [inline, static] |
A fuzzy floating point greater-then check.
static bool ai_fless | ( | float | f0, | |
float | f1, | |||
float | tol | |||
) | [inline, static] |
A fuzzy floating point less-then check.
static int ai_frnd | ( | float | f | ) | [inline, static] |
Round float to integer.
static long ai_ftol | ( | float | val | ) | [inline, static] |
fast float to int conversion (always truncates) see http://www.stereopsis.com/FPU.html for a discussion. NOTE: this works only on x86 endian machines.
static int ai_iclamp | ( | int | val, | |
int | minVal, | |||
int | maxVal | |||
) | [inline, static] |
Integer clamping.
static bool ai_isEqualFloat | ( | const float | f0, | |
const float | f1, | |||
const float | tol | |||
) | [inline, static] |
static void ai_lerp | ( | TYPE & | result, | |
const TYPE & | val0, | |||
const TYPE & | val1, | |||
float | lerpVal | |||
) | [inline, static] |
Template-based linear interpolation function used by nIpolKeyArray that can be specialized for any type.
static float ai_lerp | ( | float | x, | |
float | y, | |||
float | l | |||
) | [inline, static] |
Linearly interpolate between 2 values: ret = x + l * (y - x)
static void ai_lerp< float > | ( | float & | result, | |
const float & | val0, | |||
const float & | val1, | |||
float | lerpVal | |||
) | [inline, static] |
static void ai_lerp< int > | ( | int & | result, | |
const int & | val0, | |||
const int & | val1, | |||
float | lerpVal | |||
) | [inline, static] |
static float ai_log2 | ( | float | f | ) | [inline, static] |
static float ai_rand | ( | ) | [inline, static] |
Return a pseudo random number between 0 and 1.
static int ai_random | ( | const int | i_sides | ) | [inline, static] |
static float ai_saturate | ( | float | val | ) | [inline, static] |
Saturate a value (clamps between 0.0f and 1.0f)
static float ai_smooth | ( | float | newVal, | |
float | curVal, | |||
float | maxChange | |||
) | [inline, static] |
Smooth a new value towards an old value using a change value.
static float ai_sqrt | ( | float | x | ) | [inline, static] |
Safe sqrt.
Variable Documentation
const float AI_LN_2 = 0.693147180559945f |
log2() function.