KudanAR - iOS  1.6.0
OgreMathLib::Math Class Reference

#include <OgreMathLib.h>

Public Types

enum  AngleUnit { AU_DEGREE, AU_RADIAN }
 

Public Member Functions

 Math (unsigned int trigTableSize=4096)
 
 ~Math ()
 

Static Public Member Functions

static int IAbs (int iValue)
 
static int ICeil (float fValue)
 
static int IFloor (float fValue)
 
static int ISign (int iValue)
 
static Real Abs (Real fValue)
 
static Degree Abs (const Degree &dValue)
 
static Radian Abs (const Radian &rValue)
 
static Radian ACos (Real fValue)
 
static Radian ASin (Real fValue)
 
static Radian ATan (Real fValue)
 
static Radian ATan2 (Real fY, Real fX)
 
static Real Ceil (Real fValue)
 
static bool isNaN (Real f)
 
static Real Cos (const Radian &fValue, bool useTables=false)
 
static Real Cos (Real fValue, bool useTables=false)
 
static Real Exp (Real fValue)
 
static Real Floor (Real fValue)
 
static Real Log (Real fValue)
 
static Real Log2 (Real fValue)
 
static Real LogN (Real base, Real fValue)
 
static Real Pow (Real fBase, Real fExponent)
 
static Real Sign (Real fValue)
 
static Radian Sign (const Radian &rValue)
 
static Degree Sign (const Degree &dValue)
 
static Real Sin (const Radian &fValue, bool useTables=false)
 
static Real Sin (Real fValue, bool useTables=false)
 
static Real Sqr (Real fValue)
 
static Real Sqrt (Real fValue)
 
static Radian Sqrt (const Radian &fValue)
 
static Degree Sqrt (const Degree &fValue)
 
static Real InvSqrt (Real fValue)
 
static Real UnitRandom ()
 
static Real RangeRandom (Real fLow, Real fHigh)
 
static Real SymmetricRandom ()
 
static Real Tan (const Radian &fValue, bool useTables=false)
 
static Real Tan (Real fValue, bool useTables=false)
 
static Real DegreesToRadians (Real degrees)
 
static Real RadiansToDegrees (Real radians)
 
static bool RealEqual (Real a, Real b, Real tolerance=std::numeric_limits< Real >::epsilon())
 
static Real gaussianDistribution (Real x, Real offset=0.0f, Real scale=1.0f)
 
template<typename T >
static T Clamp (T val, T minval, T maxval)
 

Static Public Attributes

static const Real LOG2 = log(Real(2.0))
 Stored value of log(2) for frequent use.
 
static const Real POS_INFINITY = std::numeric_limits<Real>::infinity()
 
static const Real NEG_INFINITY = -std::numeric_limits<Real>::infinity()
 
static const Real PI = Real( 4.0 * atan( 1.0 ) )
 
static const Real TWO_PI = Real( 2.0 * PI )
 
static const Real HALF_PI = Real( 0.5 * PI )
 
static const Real fDeg2Rad = PI / Real(180.0)
 
static const Real fRad2Deg = Real(180.0) / PI
 

Protected Member Functions

void buildTrigTables ()
 

Static Protected Member Functions

static Real SinTable (Real fValue)
 
static Real TanTable (Real fValue)
 

Static Protected Attributes

static int mTrigTableSize
 Size of the trig tables as determined by constructor.
 
static Real mTrigTableFactor
 Radian -> index factor value ( mTrigTableSize / 2 * PI )
 
static Real * mSinTable = NULL
 
static Real * mTanTable = NULL
 

Detailed Description

Class to provide access to common mathematical functions.

Remarks
Most of the maths functions are aliased versions of the C runtime library functions. They are aliased here to provide future optimisation opportunities, either from faster RTLs or custom math approximations.
Note

This is based on MgcMath.h from Wild Magic.

Member Enumeration Documentation

◆ AngleUnit

The angular units used by the API. This functionality is now deprecated in favor of discreet angular unit types ( see Degree and Radian above ). The only place this functionality is actually still used is when parsing files. Search for usage of the Angle class for those instances

Constructor & Destructor Documentation

◆ Math()

OgreMathLib::Math::Math ( unsigned int  trigTableSize = 4096)

Default constructor.

Parameters
trigTableSizeOptional parameter to set the size of the tables used to implement Sin, Cos, Tan

◆ ~Math()

OgreMathLib::Math::~Math ( )

Default destructor.

Member Function Documentation

◆ buildTrigTables()

void OgreMathLib::Math::buildTrigTables ( )
protected

Private function to build trig tables.

◆ Clamp()

template<typename T >
static T OgreMathLib::Math::Clamp ( val,
minval,
maxval 
)
inlinestatic

Clamp a value within an inclusive range.

◆ Cos() [1/2]

static Real OgreMathLib::Math::Cos ( const Radian fValue,
bool  useTables = false 
)
inlinestatic

Cosine function.

Parameters
fValueAngle in radians
useTablesIf true, uses lookup tables rather than calculation - faster but less accurate.

◆ Cos() [2/2]

static Real OgreMathLib::Math::Cos ( Real  fValue,
bool  useTables = false 
)
inlinestatic

Cosine function.

Parameters
fValueAngle in radians
useTablesIf true, uses lookup tables rather than calculation - faster but less accurate.

◆ gaussianDistribution()

static Real OgreMathLib::Math::gaussianDistribution ( Real  x,
Real  offset = 0.0f,
Real  scale = 1.0f 
)
static

Generates a value based on the Gaussian (normal) distribution function with the given offset and scale parameters.

◆ InvSqrt()

Real OgreMathLib::Math::InvSqrt ( Real  fValue)
static

Inverse square root i.e. 1 / Sqrt(x), good for vector normalisation.

◆ RealEqual()

bool OgreMathLib::Math::RealEqual ( Real  a,
Real  b,
Real  tolerance = std::numeric_limits<Real>::epsilon() 
)
static

Compare 2 reals, using tolerance for inaccuracies.

◆ Sin() [1/2]

static Real OgreMathLib::Math::Sin ( const Radian fValue,
bool  useTables = false 
)
inlinestatic

Sine function.

Parameters
fValueAngle in radians
useTablesIf true, uses lookup tables rather than calculation - faster but less accurate.

◆ Sin() [2/2]

static Real OgreMathLib::Math::Sin ( Real  fValue,
bool  useTables = false 
)
inlinestatic

Sine function.

Parameters
fValueAngle in radians
useTablesIf true, uses lookup tables rather than calculation - faster but less accurate.

◆ Tan() [1/2]

static Real OgreMathLib::Math::Tan ( const Radian fValue,
bool  useTables = false 
)
inlinestatic

Tangent function.

Parameters
fValueAngle in radians
useTablesIf true, uses lookup tables rather than calculation - faster but less accurate.

◆ Tan() [2/2]

static Real OgreMathLib::Math::Tan ( Real  fValue,
bool  useTables = false 
)
inlinestatic

Tangent function.

Parameters
fValueAngle in radians
useTablesIf true, uses lookup tables rather than calculation - faster but less accurate.

The documentation for this class was generated from the following files: