NSMath::NSStdMath Namespace Reference

This namespace contains mathematical functions which are designed for maximal 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.
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.
float sqrt (const float &x)
 Calculate square root.
float invSqrt (const float &x)
 Calculate inverse square root (1/sqrt).
float rcp (const float &x)
 Compute reciprocal ( 1 / x ) of input value.
int maxInt (int a, int b)
 Returns maximum from two integers.
int minInt (int a, int b)
 Returns minimum from two integers.
BOOL compareFloat (const float &val1, const float &val2, const float &delta)
 Compare two float values with fiven tolerancy.

Variables

const float PI = 3.1415926535897932384626433832795f
 definition of PI
const float PI_2 = 2.0f *3.1415926535897932384626433832795f
 definition of PI*2
const float PI_HALF = PI * 0.5f
 half of PI
const float PI_INV = (1.0f / PI)
 inverse number to PI ... 1 / PI
const float PI_2_INV = (0.5f / PI)
 inverse number to PI*2 ... 1 / PI*2
const float E = 2.7182818284590452353602874713527f
 definition of E
const float FLOAT_INFINITY = 1e35f
 maximal value for our float values


Detailed Description

This namespace contains mathematical functions which are designed for maximal precision.

Names of functions are identical with names from NSFastMath, but first letter is lowercase.


Function Documentation

int NSMath::NSStdMath::abs const int &  x  )  [inline]
 

Calculates absolute value of number.

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

Definition at line 168 of file StdMath.h.

Referenced by TRendererCreatorHelper::GetClosestResolution().

float NSMath::NSStdMath::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 204 of file StdMath.h.

Referenced by NSMath::TQuaternion::GetAngle(), NSMath::TQuaternion::Ln(), NSMath::TSolvers::RootsCubicReal(), NSMath::TQuaternion::Slerp(), NSMath::TQuaternion::SlerpCompute(), NSMath::TQuaternion::SlerpFast(), and NSMath::TQuaternion::SlerpFastCompute().

float NSMath::NSStdMath::arccotangent const float &  x  )  [inline]
 

Computes arcus cotangent of given value.

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

Parameters:
x [in] value

Definition at line 263 of file StdMath.h.

References PI_HALF.

float NSMath::NSStdMath::arctangent const float &  x  )  [inline]
 

Computes arcus tangent of given value.

Parameters:
x [in] value

Definition at line 234 of file StdMath.h.

float NSMath::NSStdMath::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 244 of file StdMath.h.

Referenced by NSMath::TEulerAngles::Set().

float NSMath::NSStdMath::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 186 of file StdMath.h.

Referenced by NSMath::TEulerAngles::Set().

float NSMath::NSStdMath::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 124 of file StdMath.h.

BOOL NSMath::NSStdMath::compareFloat const float &  val1,
const float &  val2,
const float &  delta
[inline]
 

Compare two float values with fiven tolerancy.

Parameters:
val1 [in] first value
val2 [in] second value
delta [in] maximal allowed tolerancy

Definition at line 333 of file StdMath.h.

References fabs().

Referenced by TMathTest::CalcAABBoxLineSegmentProjection(), TMathTest::CalcLineSegment2DVector2DProjection(), NSMath::TLine2D::Compare(), NSMath::TCircle2D::Compare(), NSMath::TMatrix3::IsOrthonormalBasis(), NSMath::TMatrix3::IsSymmetrical(), and NSMath::TTriangle::PointBarycentricCoords().

Here is the call graph for this function:

float NSMath::NSStdMath::cos const float &  angle  )  [inline]
 

Calculate cosinus of specified angle in radians.

Parameters:
angle [in] angle in radians

Definition at line 195 of file StdMath.h.

Referenced by NSRandom::TRandomNormal::Random(), NSMath::TSolvers::RootsCubicReal(), and NSMath::TEulerAngles::Set().

float NSMath::NSStdMath::cotangent const float &  angle  )  [inline]
 

Calculate cotangent of specified angle in radians.

Parameters:
angle [in] angle in radians

Definition at line 253 of file StdMath.h.

Referenced by NSMath::TMatrix4::PerspectiveFovRH().

void NSMath::NSStdMath::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 68 of file StdMath.h.

Referenced by NSMath::NSFastMath::Div(), and NSMath::TSolvers::RootsQuadraticReal().

float NSMath::NSStdMath::exp const float &  number  )  [inline]
 

Compute e^number.

Parameters:
number [in] exponent

Definition at line 80 of file StdMath.h.

Referenced by NSMath::TBox::AddPoint().

float NSMath::NSStdMath::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 157 of file StdMath.h.

Referenced by NSMath::TVector2D::Abs(), NSMath::TPlane::AbsDistance(), NSMath::TLine2D::AbsDistance(), NSMath::TVector3::Absolute(), NSMath::TMatrix3::Absolute(), NSMath::TVector3::AbsoluteGet(), NSMath::TMatrix3::AbsoluteGet(), NSMath::TBox2D::AddPoint(), NSMath::TBox::AddPoint(), NSMath::TVector4::Compare(), NSMath::TVector3::Compare(), NSMath::TVector2D::Compare(), NSMath::TSphere::Compare(), NSMath::TPlane::Compare(), NSMath::TMatrix4::Compare(), NSMath::TMatrix3::Compare(), NSMath::TEulerAngles::Compare(), compareFloat(), NSMath::TVector2D::GetAbs(), NSMath::NSCurves::THermiteCubic::GetFirstDerivateValue(), NSMath::TBox2D::GetMaxX(), NSMath::TBox2D::GetMaxY(), NSMath::TBox2D::GetMinMaxX(), NSMath::TBox2D::GetMinMaxXY(), NSMath::TBox2D::GetMinMaxY(), NSMath::TBox2D::GetMinX(), NSMath::TBox2D::GetMinY(), NSMath::NSCurves::THermiteCubic::GetSecondDerivateValue(), NSMath::NSCurves::THermiteCubic::GetValue(), NSMath::TPlane::Intersect(), NSMath::TLine2D::Intersect(), NSMath::TLine2D::IntersectNegative(), NSMath::TPlane::IntersectPlane(), NSMath::TPlane::IntersectPoint(), NSMath::TLine2D::IntersectPoint(), NSMath::TLine2D::IntersectPointNegative(), NSMath::TLine2D::IntersectPointPositive(), NSMath::TLine2D::IntersectPositive(), NSMath::TBox2D::IsInside(), NSMath::TBox::IsInside(), NSMath::TRectangle2D::IsIntersect(), NSMath::TBox2D::IsIntersect(), NSMath::TBox::IsIntersect(), NSMath::TAABBox::IsIntersect(), NSMath::TTriangle::IsIntersectPoint(), NSMath::TCircle2D::IsIntersectPoints(), NSMath::TPlane::IsNegative(), NSMath::TLine2D::IsNegative(), NSMath::TVector4::IsNormalized(), NSMath::TVector3::IsNormalized(), NSMath::TQuaternion::IsNormalized(), NSMath::TPlane::IsOnPlane(), NSMath::TSphere::IsOnSurface(), NSMath::TRay2D::IsParallel(), NSMath::TRay::IsParallel(), NSMath::TLineSegment2D::IsParallel(), NSMath::TLineSegment::IsParallel(), NSMath::TLine2D::IsParallel(), NSMath::TLine::IsParallel(), NSMath::TRay2D::IsPerpendicular(), NSMath::TRay::IsPerpendicular(), NSMath::TLineSegment2D::IsPerpendicular(), NSMath::TLineSegment::IsPerpendicular(), NSMath::TLine2D::IsPerpendicular(), NSMath::TLine::IsPerpendicular(), NSMath::TPlane::IsPositive(), NSMath::TLine2D::IsPositive(), NSMath::TQuaternion::Ln(), NSMath::TRectangle2D::ProjectExtentsToAxis(), NSMath::TBox2D::ProjectExtentsToAxis(), NSMath::TBox::ProjectExtentsToAxis(), NSMath::TAABBox::ProjectExtentsToAxis(), NSMath::TBox2D::ProjectExtentsToX(), NSMath::TBox::ProjectExtentsToX(), NSMath::TBox2D::ProjectExtentsToY(), NSMath::TBox::ProjectExtentsToY(), NSMath::TBox::ProjectExtentsToZ(), NSMath::TRectangle2D::ProjectToAxis(), NSMath::TBox2D::ProjectToAxis(), NSMath::TAABBox::ProjectToAxis(), NSMath::TRectangle2D::ProjectToLine(), NSMath::TBox2D::ProjectToLine(), NSMath::TAABBox::ProjectToLine(), NSMath::TRectangle2D::ProjectToLineSegment(), NSMath::TBox2D::ProjectToLineSegment(), NSMath::TAABBox::ProjectToLineSegment(), NSMath::TRectangle2D::ProjectToLineSegmentNormalized(), NSMath::TBox2D::ProjectToLineSegmentNormalized(), NSMath::TAABBox::ProjectToLineSegmentNormalized(), NSMath::TRectangle2D::ProjectToRay(), NSMath::TBox2D::ProjectToRay(), NSMath::TAABBox::ProjectToRay(), NSMath::TMatrix4::RemoveSmallValues(), NSMath::TMatrix3::RemoveSmallValues(), NSMath::TEulerAngles::RemoveSmallValues(), NSMath::TSolvers::RootsCubicReal(), and NSMath::TEulerAngles::Set().

float NSMath::NSStdMath::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 113 of file StdMath.h.

Referenced by NSMath::TEulerAngles::NormalizeTo_0_PI2().

float NSMath::NSStdMath::invSqrt const float &  x  )  [inline]
 

Calculate inverse square root (1/sqrt).

Parameters:
x [in] non-negative value

Definition at line 281 of file StdMath.h.

Referenced by NSMath::TVector4::DotDenormalized(), NSMath::TVector3::DotDenormalized(), NSMath::TVector2D::DotDenormalized(), NSMath::TQuaternion::GetInverse(), NSMath::TQuaternion::Inverse(), NSMath::TQuaternion::Ln(), NSMath::TSolvers::Matrix3CM_RowEcholonForm_Householder(), NSMath::TQuaternion::MultiplyLeft(), NSMath::TQuaternion::MultiplyRight(), NSMath::TVector3::NormalizeFast(), NSMath::TVector2D::NormalizeFast(), NSMath::TQuaternion::NormalizeFast(), NSMath::TQuaternion::NormalizePrecise(), NSMath::TSolvers::RootsCubicReal(), NSMath::TQuaternion::Set(), and NSMath::TLine::SetFromPoints().

BOOL NSMath::NSStdMath::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 135 of file StdMath.h.

BOOL NSMath::NSStdMath::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 146 of file StdMath.h.

float NSMath::NSStdMath::ln const float &  number  )  [inline]
 

Computes natural logarithm of specified number.

Parameters:
number [in] value for computing logarithm

Definition at line 46 of file StdMath.h.

float NSMath::NSStdMath::log const float &  number  )  [inline]
 

Computes 10-base logarithm of specified number.

Parameters:
number [in] value for computing logarithm

Definition at line 55 of file StdMath.h.

Referenced by NSMeshes::TDeclarationManager::CreateDeclarationManager(), NSShaders::TPixelShaderManager::CreatePixelShaderManager(), TTextureManager::CreateTextureManager(), NSShaders::TVertexShaderManager::CreateVertexShaderManager(), TGlobalsMath::Destroy(), TGlobalsGraphic::Destroy(), NSMeshes::TDeclarationManager::DestroyDeclarationManager(), NSShaders::TPixelShaderManager::DestroyPixelShaderManager(), NSMeshes::TMeshManager::DestroyRendererResources(), TTextureManager::DestroyTextureManager(), NSShaders::TVertexShaderManager::DestroyVertexShaderManager(), TGlobalsMath::Initialize(), TGlobalsGraphic::Initialize(), NSMeshes::TDeclarationManager::Initialize(), NSMeshes::TMeshManager::LoadRendererResources(), NSRandom::TRandomExponential::Random(), and NSRandom::TRandomNormal::Random().

int NSMath::NSStdMath::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 304 of file StdMath.h.

int NSMath::NSStdMath::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 319 of file StdMath.h.

float NSMath::NSStdMath::pow const float &  base,
const float &  exponent
[inline]
 

Computes base^exponent.

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

Definition at line 102 of file StdMath.h.

Referenced by NSMath::TSolvers::RootsCubicReal().

float NSMath::NSStdMath::rcp const float &  x  )  [inline]
 

Compute reciprocal ( 1 / x ) of input value.

Warning:
Input value must be non-zero!!!
Parameters:
x [in] value to compute

Definition at line 292 of file StdMath.h.

float NSMath::NSStdMath::sin const float &  angle  )  [inline]
 

Calculate sinus of specified angle in radians.

Parameters:
angle [in] angle in radians

Definition at line 177 of file StdMath.h.

Referenced by NSMath::TQuaternion::Exp(), NSMath::TQuaternion::Slerp(), NSMath::TQuaternion::SlerpCompute(), NSMath::TQuaternion::SlerpFast(), and NSMath::TQuaternion::SlerpFastCompute().

void NSMath::NSStdMath::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 215 of file StdMath.h.

Referenced by NSMath::TQuaternion::Exp(), NSMath::TVector2D::Rotate(), NSMath::TRay2D::Rotate(), NSMath::TLineSegment2D::Rotate(), NSMath::TLine2D::Rotate(), NSMath::TBox2D::Rotate(), NSMath::TMatrix4::RotateAroundAxis(), NSMath::TMatrix3::RotateAroundAxis(), NSMath::TBox2D::RotateAroundCenter(), NSMath::TRay2D::RotateAroundPoint(), NSMath::TLineSegment2D::RotateAroundPoint(), NSMath::TLine2D::RotateAroundPoint(), NSMath::TBox2D::RotateAroundPoint(), NSMath::TTriangle::RotateAroundX(), NSMath::TRay::RotateAroundX(), NSMath::TLineSegment::RotateAroundX(), NSMath::TLine::RotateAroundX(), NSMath::TBox::RotateAroundX(), NSMath::TTriangle::RotateAroundY(), NSMath::TRay::RotateAroundY(), NSMath::TLineSegment::RotateAroundY(), NSMath::TLine::RotateAroundY(), NSMath::TBox::RotateAroundY(), NSMath::TTriangle::RotateAroundZ(), NSMath::TRay::RotateAroundZ(), NSMath::TLineSegment::RotateAroundZ(), NSMath::TLine::RotateAroundZ(), NSMath::TBox::RotateAroundZ(), NSMath::TVector3::RotateX(), NSMath::TMatrix4::RotateX(), NSMath::TMatrix3::RotateX(), NSMath::TMatrix4::RotateXTran(), NSMath::TVector3::RotateY(), NSMath::TMatrix4::RotateY(), NSMath::TMatrix3::RotateY(), NSMath::TMatrix4::RotateYTran(), NSMath::TVector3::RotateZ(), NSMath::TMatrix4::RotateZ(), NSMath::TMatrix3::RotateZ(), NSMath::TMatrix4::RotateZTran(), NSMath::TQuaternion::Set(), NSMath::TBox2D::SetAngle(), NSMath::TEulerAngles::ToMatrix3(), and NSMath::TEulerAngles::ToMatrix4().

void NSMath::NSStdMath::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 92 of file StdMath.h.

float NSMath::NSStdMath::sqrt const float &  x  )  [inline]
 

Calculate square root.

Parameters:
x [in] non-negative value

Definition at line 272 of file StdMath.h.

Referenced by NSMath::TSphere::AddPoint(), NSMath::TCircle2D::AddPoint(), NSMath::TTriangle::Area(), NSMath::TVector3::CrossScalar(), NSMath::TRay2D::Distance(), NSMath::TLineSegment2D::Distance(), NSMath::TBox::DistanceSurface(), NSMath::TAABBox::DistanceSurface(), NSMath::TVector3::DistanceTo(), NSMath::TVector2D::DistanceTo(), NSMath::TQuaternion::Exp(), NSMath::TQuaternion::GetAxis(), TRendererCreatorHelper::GetClosestResolution(), NSMath::TCircle2D::IsIntersectCircle2D(), NSMath::TSphere::IsIntersectPoints(), NSMath::TCircle2D::IsIntersectPoints(), NSMath::TSphere::IsIntersectPointsNormalized(), NSMath::TCircle2D::IsIntersectPointsNormalized(), NSMath::TSphere::IsIntersectsSphere(), NSMath::TVector4::Length(), NSMath::TVector2D::Length(), NSMath::TQuaternion::Length(), NSMath::TMatrix4::LookAtRHStdUp(), NSMath::TSolvers::Matrix3CM_RowEcholonForm_Householder(), NSMath::TVector4::Normalize(), NSMath::TVector3::Normalize(), NSMath::TQuaternion::Normalize(), NSMath::TVector4::NormalizeFast(), NSMath::TVector3::NormalizePrecise(), NSRandom::TRandomNormal::Random(), NSMath::TSolvers::RootsCubicReal(), NSMath::TSolvers::RootsQuadraticReal(), NSMath::TSphere::Set(), NSMath::TCircle2D::Set(), NSMath::TSphere::SetFromPoints(), NSMath::TCircle2D::SetRadiusSquare(), TCameraClassic::TCameraClassic(), and NSMath::TSphere::TSphere().

float NSMath::NSStdMath::tangent const float &  angle  )  [inline]
 

Calculate tangent of specified angle in radians.

Parameters:
angle [in] angle in radians

Definition at line 225 of file StdMath.h.

Referenced by NSMath::NSCurves::THermiteCubicSpline::AddPoint(), and NSMath::NSCurves::THermiteCubicSpline::ChangeTangent().


Variable Documentation

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

definition of E

Definition at line 38 of file StdMath.h.

const float NSMath::NSStdMath::FLOAT_INFINITY = 1e35f
 

maximal value for our float values

Definition at line 40 of file StdMath.h.

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

definition of PI

Definition at line 32 of file StdMath.h.

Referenced by NSMath::TCircle2D::Area(), NSMath::TSolvers::RootsCubicReal(), NSMath::TSphere::Surface(), and NSMath::TSphere::Volume().

const float NSMath::NSStdMath::PI_2 = 2.0f *3.1415926535897932384626433832795f
 

definition of PI*2

Definition at line 33 of file StdMath.h.

Referenced by NSMath::TEulerAngles::NormalizeTo_0_PI2(), and NSMath::TCircle2D::Perimeter().

const float NSMath::NSStdMath::PI_2_INV = (0.5f / PI)
 

inverse number to PI*2 ... 1 / PI*2

Definition at line 36 of file StdMath.h.

Referenced by NSMath::TEulerAngles::NormalizeTo_0_PI2().

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

half of PI

Definition at line 34 of file StdMath.h.

Referenced by arccotangent().

const float NSMath::NSStdMath::PI_INV = (1.0f / PI)
 

inverse number to PI ... 1 / PI

Definition at line 35 of file StdMath.h.


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