orx  stable
Portable Game Engine
OrxMath

Macros

#define orxCLAMP(V, MIN, MAX)    orxMAX(orxMIN(V, MAX), MIN)
 
#define orxF2S(V)    ((orxS32) (V))
 
#define orxF2U(V)    ((orxU32) (V))
 
#define orxLERP(A, B, T)    ((A) + ((T) * ((B) - (A))))
 
#define orxMATH_KF_2_PI   orx2F(6.283185307f)
 
#define orxMATH_KF_DEG_TO_RAD   orx2F(3.141592654f / 180.0f)
 
#define orxMATH_KF_EPSILON   orx2F(0.0001f)
 
#define orxMATH_KF_PI   orx2F(3.141592654f)
 
#define orxMATH_KF_PI_BY_2   orx2F(1.570796327f)
 
#define orxMATH_KF_PI_BY_4   orx2F(0.785398163f)
 
#define orxMATH_KF_RAD_TO_DEG   orx2F(180.0f / 3.141592654f)
 
#define orxMATH_KF_SQRT_2   orx2F(1.414213562f)
 
#define orxMATH_KF_TINY_EPSILON   orx2F(1.0e-037f)
 
#define orxMAX(A, B)    (((A) < (B)) ? (B) : (A))
 
#define orxMIN(A, B)    (((A) > (B)) ? (B) : (A))
 
#define orxS2F(V)    ((orxFLOAT)(V))
 
#define orxU2F(V)    ((orxFLOAT)(V))
 

Functions

static orxINLINE orxFLOAT orxMath_Abs (orxFLOAT _fOp)
 
static orxINLINE orxFLOAT orxMath_ACos (orxFLOAT _fOp)
 
static orxINLINE orxFLOAT orxMath_ASin (orxFLOAT _fOp)
 
static orxINLINE orxFLOAT orxMath_ATan (orxFLOAT _fOp1, orxFLOAT _fOp2)
 
static orxINLINE orxFLOAT orxMath_Ceil (orxFLOAT _fOp)
 
static orxINLINE orxFLOAT orxMath_Cos (orxFLOAT _fOp)
 
static orxINLINE orxFLOAT orxMath_Floor (orxFLOAT _fOp)
 
static orxINLINE orxU32 orxMath_GetBitCount (orxU32 _u32Value)
 
static orxINLINE orxU32 orxMath_GetNextPowerOfTwo (orxU32 _u32Value)
 
orxDLLAPI orxFLOAT orxFASTCALL orxMath_GetRandomFloat (orxFLOAT _fMin, orxFLOAT _fMax)
 
orxDLLAPI orxS32 orxFASTCALL orxMath_GetRandomS32 (orxS32 _s32Min, orxS32 _s32Max)
 
orxDLLAPI orxS64 orxFASTCALL orxMath_GetRandomS64 (orxS64 _s64Min, orxS64 _s64Max)
 
orxDLLAPI void orxFASTCALL orxMath_GetRandomSeeds (orxU32 _au32Seeds[4])
 
orxDLLAPI orxU32 orxFASTCALL orxMath_GetRandomU32 (orxU32 _u32Min, orxU32 _u32Max)
 
orxDLLAPI orxU64 orxFASTCALL orxMath_GetRandomU64 (orxU64 _u64Min, orxU64 _u64Max)
 
static orxINLINE orxU32 orxMath_GetTrailingZeroCount (orxU32 _u32Value)
 
orxDLLAPI void orxFASTCALL orxMath_InitRandom (orxU32 _u32Seed)
 
static orxINLINE orxBOOL orxMath_IsPowerOfTwo (orxU32 _u32Value)
 
static orxINLINE orxFLOAT orxMath_Mod (orxFLOAT _fOp1, orxFLOAT _fOp2)
 
static orxINLINE orxFLOAT orxMath_Pow (orxFLOAT _fOp, orxFLOAT _fExp)
 
static orxINLINE orxFLOAT orxMath_Round (orxFLOAT _fOp)
 
orxDLLAPI void orxFASTCALL orxMath_SetRandomSeeds (const orxU32 _au32Seeds[4])
 
static orxINLINE orxFLOAT orxMath_Sin (orxFLOAT _fOp)
 
static orxINLINE orxFLOAT orxMath_SmootherStep (orxFLOAT _fMin, orxFLOAT _fMax, orxFLOAT _fValue)
 
static orxINLINE orxFLOAT orxMath_SmoothStep (orxFLOAT _fMin, orxFLOAT _fMax, orxFLOAT _fValue)
 
static orxINLINE orxFLOAT orxMath_Sqrt (orxFLOAT _fOp)
 
static orxINLINE orxFLOAT orxMath_Tan (orxFLOAT _fOp)
 

Detailed Description

Math module Contains all base math functions

Macro Definition Documentation

#define orxCLAMP (   V,
  MIN,
  MAX 
)    orxMAX(orxMIN(V, MAX), MIN)

Gets clamped value between two boundaries

Parameters
[in]VValue to clamp
[in]MINMinimum boundary
[in]MAXMaximum boundary
Returns
Clamped value between MIN & MAX

Definition at line 86 of file orxMath.h.

#define orxF2S (   V)    ((orxS32) (V))

Converts an orxFLOAT to an orxS32

Parameters
[in]VValue to convert
Returns
Converted value

Definition at line 98 of file orxMath.h.

#define orxF2U (   V)    ((orxU32) (V))

Converts an orxFLOAT to an orxU32

Parameters
[in]VValue to convert
Returns
Converted value

Definition at line 92 of file orxMath.h.

#define orxLERP (   A,
  B,
 
)    ((A) + ((T) * ((B) - (A))))

Maths related includesPublic macro Lerps between two values given a parameter T [0, 1]

Parameters
[in]AFirst value (will be selected for T = 0)
[in]BSecond value (will be selected for T = 1)
[in]TLerp coefficient parameter [0, 1]
Returns
Lerped value

Definition at line 63 of file orxMath.h.

#define orxMATH_KF_2_PI   orx2F(6.283185307f)

2 PI constant

Definition at line 292 of file orxMath.h.

#define orxMATH_KF_DEG_TO_RAD   orx2F(3.141592654f / 180.0f)

Degree to radian conversion constant

Definition at line 296 of file orxMath.h.

#define orxMATH_KF_EPSILON   orx2F(0.0001f)

Epsilon constant

Definition at line 290 of file orxMath.h.

#define orxMATH_KF_PI   orx2F(3.141592654f)

PI constant

Definition at line 293 of file orxMath.h.

#define orxMATH_KF_PI_BY_2   orx2F(1.570796327f)

PI / 2 constant

Definition at line 294 of file orxMath.h.

#define orxMATH_KF_PI_BY_4   orx2F(0.785398163f)

PI / 4 constant

Definition at line 295 of file orxMath.h.

#define orxMATH_KF_RAD_TO_DEG   orx2F(180.0f / 3.141592654f)

Radian to degree conversion constant

Definition at line 297 of file orxMath.h.

#define orxMATH_KF_SQRT_2   orx2F(1.414213562f)

Sqrt(2) constant

Definition at line 289 of file orxMath.h.

#define orxMATH_KF_TINY_EPSILON   orx2F(1.0e-037f)

Tiny epsilon

Definition at line 291 of file orxMath.h.

#define orxMAX (   A,
 
)    (((A) < (B)) ? (B) : (A))

Gets maximum between two values

Parameters
[in]AFirst value
[in]BSecond value
Returns
Maximum between A & B

Definition at line 78 of file orxMath.h.

#define orxMIN (   A,
 
)    (((A) > (B)) ? (B) : (A))

Gets minimum between two values

Parameters
[in]AFirst value
[in]BSecond value
Returns
Minimum between A & B

Definition at line 71 of file orxMath.h.

#define orxS2F (   V)    ((orxFLOAT)(V))

Converts an orxS32 to an orxFLOAT

Parameters
[in]VValue to convert
Returns
Converted value

Definition at line 110 of file orxMath.h.

#define orxU2F (   V)    ((orxFLOAT)(V))

Converts an orxU32 to an orxFLOAT

Parameters
[in]VValue to convert
Returns
Converted value

Definition at line 104 of file orxMath.h.

Function Documentation

static orxINLINE orxFLOAT orxMath_Abs ( orxFLOAT  _fOp)
static

Gets an absolute value

Parameters
[in]_fOpInput value
Returns
Absolute value

Definition at line 501 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_ACos ( orxFLOAT  _fOp)
static

Gets an arccosine

Parameters
[in]_fOpInput radian angle value
Returns
Arccosine of the given angle

Definition at line 351 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_ASin ( orxFLOAT  _fOp)
static

Gets an arcsine

Parameters
[in]_fOpInput radian angle value
Returns
Arcsine of the given angle

Definition at line 366 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_ATan ( orxFLOAT  _fOp1,
orxFLOAT  _fOp2 
)
static

Gets an arctangent

Parameters
[in]_fOp1First operand
[in]_fOp2Second operand
Returns
Arctangent of the given angle

Definition at line 382 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_Ceil ( orxFLOAT  _fOp)
static

Gets a ceiled value

Parameters
[in]_fOpInput value
Returns
Ceiled value

Definition at line 430 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_Cos ( orxFLOAT  _fOp)
static

Gets a cosine

Parameters
[in]_fOpInput radian angle value
Returns
Cosine of the given angle

Definition at line 321 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_Floor ( orxFLOAT  _fOp)
static

Gets a floored value

Parameters
[in]_fOpInput value
Returns
Floored value

Definition at line 415 of file orxMath.h.

static orxINLINE orxU32 orxMath_GetBitCount ( orxU32  _u32Value)
static

Gets the count of bit in an orxU32

Parameters
[in]_u32ValueValue to process
Returns
Number of bits that are set in the value

Definition at line 172 of file orxMath.h.

static orxINLINE orxU32 orxMath_GetNextPowerOfTwo ( orxU32  _u32Value)
static

Gets next power of two of an orxU32

Parameters
[in]_u32ValueValue to process
Returns
If _u32Value is already a power of two, returns it, otherwise the next power of two

Definition at line 218 of file orxMath.h.

orxDLLAPI orxFLOAT orxFASTCALL orxMath_GetRandomFloat ( orxFLOAT  _fMin,
orxFLOAT  _fMax 
)

Gets a random orxFLOAT value

Parameters
[in]_fMinMinimum boundary (inclusive)
[in]_fMaxMaximum boundary (exclusive)
Returns
Random value
orxDLLAPI orxS32 orxFASTCALL orxMath_GetRandomS32 ( orxS32  _s32Min,
orxS32  _s32Max 
)

Gets a random orxS32 value

Parameters
[in]_s32MinMinimum boundary (inclusive)
[in]_s32MaxMaximum boundary (inclusive)
Returns
Random value
orxDLLAPI orxS64 orxFASTCALL orxMath_GetRandomS64 ( orxS64  _s64Min,
orxS64  _s64Max 
)

Gets a random orxS64 value

Parameters
[in]_s64MinMinimum boundary (inclusive)
[in]_s64MaxMaximum boundary (inclusive)
Returns
Random value
orxDLLAPI void orxFASTCALL orxMath_GetRandomSeeds ( orxU32  _au32Seeds[4])

Gets the current random seeds

Parameters
[out]_au32SeedsCurrent seeds
orxDLLAPI orxU32 orxFASTCALL orxMath_GetRandomU32 ( orxU32  _u32Min,
orxU32  _u32Max 
)

Gets a random orxU32 value

Parameters
[in]_u32MinMinimum boundary (inclusive)
[in]_u32MaxMaximum boundary (inclusive)
Returns
Random value
orxDLLAPI orxU64 orxFASTCALL orxMath_GetRandomU64 ( orxU64  _u64Min,
orxU64  _u64Max 
)

Gets a random orxU64 value

Parameters
[in]_u64MinMinimum boundary (inclusive)
[in]_u64MaxMaximum boundary (inclusive)
Returns
Random value
static orxINLINE orxU32 orxMath_GetTrailingZeroCount ( orxU32  _u32Value)
static

Gets the count of trailing zeros in an orxU32

Parameters
[in]_u32ValueValue to process
Returns
Number of trailing zeros

Definition at line 186 of file orxMath.h.

orxDLLAPI void orxFASTCALL orxMath_InitRandom ( orxU32  _u32Seed)

Inits the random seed

Parameters
[in]_u32SeedValue to use as seed for random number generation
static orxINLINE orxBOOL orxMath_IsPowerOfTwo ( orxU32  _u32Value)
static

Is value a power of two?

Parameters
[in]_u32ValueValue to test
Returns
orxTRUE / orxFALSE

Definition at line 203 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_Mod ( orxFLOAT  _fOp1,
orxFLOAT  _fOp2 
)
static

Gets a modulo value

Parameters
[in]_fOp1Input value
[in]_fOp2Modulo value
Returns
Modulo value

Definition at line 470 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_Pow ( orxFLOAT  _fOp,
orxFLOAT  _fExp 
)
static

Gets a powed value

Parameters
[in]_fOpInput value
[in]_fExpExponent value
Returns
Powed value

Definition at line 486 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_Round ( orxFLOAT  _fOp)
static

Gets a rounded value

Parameters
[in]_fOpInput value
Returns
Rounded value

Definition at line 445 of file orxMath.h.

orxDLLAPI void orxFASTCALL orxMath_SetRandomSeeds ( const orxU32  _au32Seeds[4])

Sets (replaces) the current random seeds

Parameters
[in]_au32SeedsSeeds to set
static orxINLINE orxFLOAT orxMath_Sin ( orxFLOAT  _fOp)
static

Gets a sine

Parameters
[in]_fOpInput radian angle value
Returns
Sine of the given angle

Definition at line 306 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_SmootherStep ( orxFLOAT  _fMin,
orxFLOAT  _fMax,
orxFLOAT  _fValue 
)
static

Gets smoother stepped value between two extrema

Parameters
[in]_fMinMinimum value
[in]_fMaxMaximum value
[in]_fValueValue to process
Returns
0.0 if _fValue <= _fMin, 1.0 if _fValue >= _fMax, smooth(er)ed value between 0.0 & 1.0 otherwise

Definition at line 271 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_SmoothStep ( orxFLOAT  _fMin,
orxFLOAT  _fMax,
orxFLOAT  _fValue 
)
static

Gets smooth stepped value between two extrema

Parameters
[in]_fMinMinimum value
[in]_fMaxMaximum value
[in]_fValueValue to process
Returns
0.0 if _fValue <= _fMin, 1.0 if _fValue >= _fMax, smoothed value between 0.0 & 1.0 otherwise

Definition at line 250 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_Sqrt ( orxFLOAT  _fOp)
static

Gets a square root

Parameters
[in]_fOpInput value
Returns
Square root of the given value

Definition at line 400 of file orxMath.h.

static orxINLINE orxFLOAT orxMath_Tan ( orxFLOAT  _fOp)
static

Gets a tangent

Parameters
[in]_fOpInput radian angle value
Returns
Tangent of the given angle

Definition at line 336 of file orxMath.h.


Generated for orx by doxygen 1.5.6