NSMath::NSFastMath Namespace Reference

This namespace contains mathematical functions which are designed for maximal speed at the cost of low precision. More...


Functions

float Ln (const float &number)
 Computes natural logarithm of specified number.
float Log (const float &number)
 Computes 10-base logarithm of specified number.
void Div (const int &number, const int &divider, int &quotient, int &remainder)
 This function divides number with specified divider and return quotient and remainder.
float Exp (const float &number)
 Compute e^number.
void SplitFloat (const float &number, float &integerPart, float &floatPart)
 Divides specified number into integer part and float part (part after floating-point comma).
float Pow (const float &base, const float &exponent)
 Computes base^exponent.
float Floor (const float &f)
 Computes the floor of value.
float Ceil (const float &f)
 Computes the ceil of value.
BOOL IsPowerOfTwoINT (const int &x)
 Determines whether integer number is power of two.
BOOL IsPowerOfTwoUINT (const unsigned int &x)
 Determines whether unsigned integer number is power of two.
float Fabs (const float &x)
 Calculates absolute value of floating-point number.
int Abs (const int &x)
 Calculates absolute value of number.
float Sin (const float &angle)
 Calculate sinus of specified angle in radians.
float Asin (const float &x)
 Calculate arc-sinus of specified angle in range <-1,1>.
float Cos (const float &angle)
 Calculate cosinus of specified angle in radians.
float Acos (const float &x)
 Calculate arc-cosinus of specified angle in range <-1,1>.
void SinCos (const float &angle, float &r_sin, float &r_cos)
 Calculate cosinus and sinus for specified angle in radians.
float Tangent (const float &angle)
 Calculate tangent of specified angle in radians.
float ArcTangent (const float &x)
 Computes arcus tangent of given value which must be in range <-1,1>.
float ArcTangent2 (const float &y, const float &x)
 Compute arcus tangent of (y/x) and return result in range <-PI,PI>.
float Cotangent (const float &angle)
 Calculate cotangent of specified angle in radians.
float ArcCotangent (const float &x)
 Computes arcus cotangent of given value which must be in range <-1,1>.
float Sqrt (const float &x)
 Calculate square root.
float InvSqrt (const float &x)
 Calculate inverse square root (1/sqrt).
int MaxInt (int a, int b)
 Returns maximum from two integers.
int MinInt (int a, int b)
 Returns minimum from two integers.

Variables

const float PI = 3.1415926535897932384626433832795f
 definition of PI
const float PI_HALF = PI * 0.5f
 half of PI
const float E = 2.7182818284590452353602874713527f
 definition of E


Detailed Description

This namespace contains mathematical functions which are designed for maximal speed at the cost of low precision.

If application doesn't need speed then standard math routines should be used (from StdMath namespace).

Names of functions are identical with names from NSStdMath, but first letter is uppercase.


Function Documentation

int NSMath::NSFastMath::Abs const int &  x  )  [inline]
 

Calculates absolute value of number.

Parameters:
x [in] given number
Returns:
absolute value of number

Definition at line 163 of file FastMath.h.

float NSMath::NSFastMath::Acos const float &  x  )  [inline]
 

Calculate arc-cosinus of specified angle in range <-1,1>.

Parameters:
x [in] value in range <-1,1>

Definition at line 199 of file FastMath.h.

float NSMath::NSFastMath::ArcCotangent const float &  x  )  [inline]
 

Computes arcus cotangent of given value which must be in range <-1,1>.

Its computed as (PI/2) - arctan(x).

Parameters:
x [in] value in range <-1,1>

Definition at line 261 of file FastMath.h.

References DBGASSERT, and PI_HALF.

float NSMath::NSFastMath::ArcTangent const float &  x  )  [inline]
 

Computes arcus tangent of given value which must be in range <-1,1>.

Parameters:
x [in] value in range <-1,1>

Definition at line 229 of file FastMath.h.

References DBGASSERT.

float NSMath::NSFastMath::ArcTangent2 const float &  y,
const float &  x
[inline]
 

Compute arcus tangent of (y/x) and return result in range <-PI,PI>.

If X is 0 then 0 is returned, if both parameters are 0 then 0 is returned.

Parameters:
y [in] value
x [in] value

Definition at line 242 of file FastMath.h.

float NSMath::NSFastMath::Asin const float &  x  )  [inline]
 

Calculate arc-sinus of specified angle in range <-1,1>.

Parameters:
x [in] value in range <-1,1>

Definition at line 181 of file FastMath.h.

float NSMath::NSFastMath::Ceil const float &  f  )  [inline]
 

Computes the ceil of value.

Parameters:
f [in] float value to compute
Returns:
ceil of given value

Definition at line 119 of file FastMath.h.

float NSMath::NSFastMath::Cos const float &  angle  )  [inline]
 

Calculate cosinus of specified angle in radians.

Parameters:
angle [in] angle in radians

Definition at line 190 of file FastMath.h.

float NSMath::NSFastMath::Cotangent const float &  angle  )  [inline]
 

Calculate cotangent of specified angle in radians.

Parameters:
angle [in] angle in radians

Definition at line 251 of file FastMath.h.

void NSMath::NSFastMath::Div const int &  number,
const int &  divider,
int &  quotient,
int &  remainder
[inline]
 

This function divides number with specified divider and return quotient and remainder.

Its fast solution, because computing remainder and quotinent is performed as one instruction.

Parameters:
number [in] dividend
divider [in] divider
quotient [out] returned quotient
remainder [out] returned remainder

Definition at line 63 of file FastMath.h.

References NSMath::NSStdMath::div().

Here is the call graph for this function:

float NSMath::NSFastMath::Exp const float &  number  )  [inline]
 

Compute e^number.

Parameters:
number [in] exponent

Definition at line 75 of file FastMath.h.

float NSMath::NSFastMath::Fabs const float &  x  )  [inline]
 

Calculates absolute value of floating-point number.

Parameters:
x [in] given floating-point number
Returns:
absolute value of floating-point number

Definition at line 152 of file FastMath.h.

float NSMath::NSFastMath::Floor const float &  f  )  [inline]
 

Computes the floor of value.

Parameters:
f [in] float value to compute
Returns:
floor of given value

Definition at line 108 of file FastMath.h.

float NSMath::NSFastMath::InvSqrt const float &  x  )  [inline]
 

Calculate inverse square root (1/sqrt).

Parameters:
x [in] non-negative value

Definition at line 281 of file FastMath.h.

BOOL NSMath::NSFastMath::IsPowerOfTwoINT const int &  x  )  [inline]
 

Determines whether integer number is power of two.

Parameters:
x [in] given integer number
Returns:
TRUE if given number is power of two, otherwise returns FALSE

Definition at line 130 of file FastMath.h.

BOOL NSMath::NSFastMath::IsPowerOfTwoUINT const unsigned int &  x  )  [inline]
 

Determines whether unsigned integer number is power of two.

Parameters:
x [in] given unsigned integer number
Returns:
TRUE if given number is power of two, otherwise returns FALSE

Definition at line 141 of file FastMath.h.

float NSMath::NSFastMath::Ln const float &  number  )  [inline]
 

Computes natural logarithm of specified number.

Parameters:
number [in] value for computing logarithm

Definition at line 41 of file FastMath.h.

float NSMath::NSFastMath::Log const float &  number  )  [inline]
 

Computes 10-base logarithm of specified number.

Parameters:
number [in] value for computing logarithm

Definition at line 50 of file FastMath.h.

int NSMath::NSFastMath::MaxInt int  a,
int  b
[inline]
 

Returns maximum from two integers.

Parameters:
a [in] first operand
b [in] second operand
Returns:
maximum from two integers

Definition at line 293 of file FastMath.h.

int NSMath::NSFastMath::MinInt int  a,
int  b
[inline]
 

Returns minimum from two integers.

Parameters:
a [in] first operand
b [in] second operand
Returns:
minimum from two integers

Definition at line 307 of file FastMath.h.

float NSMath::NSFastMath::Pow const float &  base,
const float &  exponent
[inline]
 

Computes base^exponent.

Parameters:
base [in] base
exponent [in] exponent

Definition at line 97 of file FastMath.h.

float NSMath::NSFastMath::Sin const float &  angle  )  [inline]
 

Calculate sinus of specified angle in radians.

Parameters:
angle [in] angle in radians

Definition at line 172 of file FastMath.h.

void NSMath::NSFastMath::SinCos const float &  angle,
float &  r_sin,
float &  r_cos
[inline]
 

Calculate cosinus and sinus for specified angle in radians.

Parameters:
angle [in] angle in radians
r_sin [out] variable for storing result of sinus
r_cos [out] variable for storing result of cosinus

Definition at line 210 of file FastMath.h.

Referenced by TCameraClassic::Rotate(), and TCameraClassic::RotateAndZoom().

void NSMath::NSFastMath::SplitFloat const float &  number,
float &  integerPart,
float &  floatPart
[inline]
 

Divides specified number into integer part and float part (part after floating-point comma).

Integer part is still float's type, but can be re-typed to INT value without losing precision.

Parameters:
number [in] input number
integerPart [out] returned integer part of number
floatPart [out] returned fractional part from input number

Definition at line 87 of file FastMath.h.

float NSMath::NSFastMath::Sqrt const float &  x  )  [inline]
 

Calculate square root.

Parameters:
x [in] non-negative value

Definition at line 272 of file FastMath.h.

Referenced by NSMath::TVector3::Length(), TCameraClassic::Rotate(), and TCameraClassic::RotateAndZoom().

float NSMath::NSFastMath::Tangent const float &  angle  )  [inline]
 

Calculate tangent of specified angle in radians.

Parameters:
angle [in] angle in radians

Definition at line 220 of file FastMath.h.


Variable Documentation

const float NSMath::NSFastMath::E = 2.7182818284590452353602874713527f
 

definition of E

Definition at line 35 of file FastMath.h.

const float NSMath::NSFastMath::PI = 3.1415926535897932384626433832795f
 

definition of PI

Definition at line 33 of file FastMath.h.

const float NSMath::NSFastMath::PI_HALF = PI * 0.5f
 

half of PI

Definition at line 34 of file FastMath.h.

Referenced by ArcCotangent(), TMathTest::ConvEulerAnglesMatrix3(), and TMathTest::ConvEulerAnglesMatrix4().


Generated on Wed Nov 28 23:08:10 2007 for Joy4D by  doxygen 1.4.6-NO