orx  1.14
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_MAX   orx2F(3.402823466e+38F)
 
#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)
 
orxDLLAPI orxFLOAT orxFASTCALL orxMath_GetSteppedRandomFloat (orxFLOAT _fMin, orxFLOAT _fMax, orxFLOAT _fStep)
 
orxDLLAPI orxS32 orxFASTCALL orxMath_GetSteppedRandomS32 (orxS32 _s32Min, orxS32 _s32Max, orxS32 _s32Step)
 
orxDLLAPI orxS64 orxFASTCALL orxMath_GetSteppedRandomS64 (orxS64 _s64Min, orxS64 _s64Max, orxS64 _s64Step)
 
orxDLLAPI orxU32 orxFASTCALL orxMath_GetSteppedRandomU32 (orxU32 _u32Min, orxU32 _u32Max, orxU32 _u32Step)
 
orxDLLAPI orxU64 orxFASTCALL orxMath_GetSteppedRandomU64 (orxU64 _u64Min, orxU64 _u64Max, orxU64 _u64Step)
 
static orxINLINE orxU32 orxMath_GetTrailingZeroCount (orxU32 _u32Value)
 
static orxINLINE orxU32 orxMath_GetTrailingZeroCount64 (orxU64 _u64Value)
 
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 89 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 101 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 95 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 66 of file orxMath.h.

#define orxMATH_KF_2_PI   orx2F(6.283185307f)

2 PI constant

Definition at line 392 of file orxMath.h.

#define orxMATH_KF_DEG_TO_RAD   orx2F(3.141592654f / 180.0f)

Degree to radian conversion constant

Definition at line 396 of file orxMath.h.

#define orxMATH_KF_EPSILON   orx2F(0.0001f)

Epsilon constant

Definition at line 389 of file orxMath.h.

#define orxMATH_KF_MAX   orx2F(3.402823466e+38F)

Max constant

Definition at line 391 of file orxMath.h.

#define orxMATH_KF_PI   orx2F(3.141592654f)

PI constant

Definition at line 393 of file orxMath.h.

#define orxMATH_KF_PI_BY_2   orx2F(1.570796327f)

PI / 2 constant

Definition at line 394 of file orxMath.h.

#define orxMATH_KF_PI_BY_4   orx2F(0.785398163f)

PI / 4 constant

Definition at line 395 of file orxMath.h.

#define orxMATH_KF_RAD_TO_DEG   orx2F(180.0f / 3.141592654f)

Radian to degree conversion constant

Definition at line 397 of file orxMath.h.

#define orxMATH_KF_SQRT_2   orx2F(1.414213562f)

Sqrt(2) constant

Definition at line 388 of file orxMath.h.

#define orxMATH_KF_TINY_EPSILON   orx2F(1.0e-037f)

Tiny epsilon

Definition at line 390 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 81 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 74 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 113 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 107 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 601 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 451 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 466 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 482 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 530 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 421 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 515 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 215 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 317 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
orxDLLAPI orxFLOAT orxFASTCALL orxMath_GetSteppedRandomFloat ( orxFLOAT  _fMin,
orxFLOAT  _fMax,
orxFLOAT  _fStep 
)

Gets a random orxFLOAT value using step increments

Parameters
[in]_fMinMinimum boundary (inclusive)
[in]_fMaxMaximum boundary (inclusive)
[in]_fStepStep value, must be strictly positive
Returns
Random value
orxDLLAPI orxS32 orxFASTCALL orxMath_GetSteppedRandomS32 ( orxS32  _s32Min,
orxS32  _s32Max,
orxS32  _s32Step 
)

Gets a random S32 value using step increments

Parameters
[in]_s32MinMinimum boundary (inclusive)
[in]_s32MaxMaximum boundary (inclusive)
[in]_s32StepStep value, must be strictly positive
Returns
Random value
orxDLLAPI orxS64 orxFASTCALL orxMath_GetSteppedRandomS64 ( orxS64  _s64Min,
orxS64  _s64Max,
orxS64  _s64Step 
)

Gets a random S64 value using step increments

Parameters
[in]_s64MinMinimum boundary (inclusive)
[in]_s64MaxMaximum boundary (inclusive)
[in]_s64StepStep value, must be strictly positive
Returns
Random value
orxDLLAPI orxU32 orxFASTCALL orxMath_GetSteppedRandomU32 ( orxU32  _u32Min,
orxU32  _u32Max,
orxU32  _u32Step 
)

Gets a random U32 value using step increments

Parameters
[in]_u32MinMinimum boundary (inclusive)
[in]_u32MaxMaximum boundary (inclusive)
[in]_u32StepStep value, must be strictly positive
Returns
Random value
orxDLLAPI orxU64 orxFASTCALL orxMath_GetSteppedRandomU64 ( orxU64  _u64Min,
orxU64  _u64Max,
orxU64  _u64Step 
)

Gets a random U64 value using step increments

Parameters
[in]_u64MinMinimum boundary (inclusive)
[in]_u64MaxMaximum boundary (inclusive)
[in]_u64StepStep value, must be strictly positive
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 239 of file orxMath.h.

static orxINLINE orxU32 orxMath_GetTrailingZeroCount64 ( orxU64  _u64Value)
static

Gets the count of trailing zeros in an orxU64

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

Definition at line 266 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 302 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 570 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 586 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 545 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 406 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 370 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 349 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 500 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 436 of file orxMath.h.


Generated for orx by doxygen 1.8.11