K3dMath Class Reference

#include <K3dMath.h>

List of all members.

Public Member Functions

 K3dMath ()
 ~K3dMath ()

Static Public Member Functions

static bool IsOddNumber (int i)
static float ACos (const float fValue)
static float ASin (const float fValue)
static float ATan (const float fValue)
static float ATan2 (const float fY, const float fX)
static float Ceil (const float fValue)
static float Cos (const float fValue)
static float Exp (const float fValue)
static float FAbs (const float fValue)
static float Floor (const float fValue)
static float FMod (const float fX, const float fY)
static float InvSqrt (const float fValue)
static float Log (const float fValue)
static float Pow (const float fBase, const float fExponent)
static float Sin (const float fValue)
static float Sqr (const float fValue)
static float Sqrt (const float fValue)
static float Tan (const float fValue)
static int Sign (const int iValue)
static int Sign (const float fValue)
static float FastSin0 (const float fAngle)
static float FastSin1 (const float fAngle)
static float FastCos0 (const float fAngle)
static float FastCos1 (const float fAngle)
static float FastTan0 (const float fAngle)
static float FastTan1 (const float fAngle)
static float FastASin (const float fValue)
static float FastACos (const float fValue)
static float FastATan0 (const float fValue)
static float FastATan1 (const float fValue)
static float UnitRandom (const float fSeed=(float) 0.0)
static float SymmetricRandom (const float fSeed=(float) 0.0)
static float IntervalRandom (const float fMin, const float fMax, const float fSeed=(float) 0.0)
static float Positive (const float fValue)
 If value negative change to the positive.
static int Positive (const int iValue)
 If value negative change to the positive.
static float Negative (const float fValue)
 If value positive change to the negative.
static int Negative (const int iValue)
 If value positive change to the negative.
static bool EqualRange (const float _f0, const float _f1, const float _fRange)
 Is equal two values by range ?

Static Public Attributes

static const float EPSILON
 Common constants.
static const float MAX_REAL
static const float K_PI
static const float TWO_PI
static const float HALF_PI
static const float QUARTER_PI
static const float THREE_HALF_PI
static const float INV_PI
static const float INV_TWO_PI
static const float K_DEG_TO_RAD
static const float K_RAD_TO_DEG
static const float K_FI
 Fibonacci traditional value (Golden ratio).

Static Private Member Functions

static float ConvertHalfPiSin (const float fAngle, bool &rbNeg)
 Convert to PI/2 for fast sin, cos functions bbb Kde se tohle zobrazi????
static float ConvertHalfPiCos (const float fAngle, bool &rbNeg)
static float ConvertTwoPi (const float fAngle)


Detailed Description

Definition at line 38 of file K3dMath.h.


Constructor & Destructor Documentation

K3dMath::K3dMath (  ) 

Definition at line 33 of file K3dMath.cpp.

K3dMath::~K3dMath (  ) 

Definition at line 37 of file K3dMath.cpp.


Member Function Documentation

float K3dMath::ConvertHalfPiSin ( const float  fAngle,
bool &  rbNeg 
) [inline, static, private]

Convert to PI/2 for fast sin, cos functions bbb Kde se tohle zobrazi????

Definition at line 288 of file K3dMath.h.

References HALF_PI, K_PI, THREE_HALF_PI, and TWO_PI.

Referenced by FastSin0(), and FastSin1().

float K3dMath::ConvertHalfPiCos ( const float  fAngle,
bool &  rbNeg 
) [inline, static, private]

Definition at line 366 of file K3dMath.h.

References HALF_PI, K_PI, THREE_HALF_PI, and TWO_PI.

Referenced by FastCos0(), and FastCos1().

float K3dMath::ConvertTwoPi ( const float  fAngle  )  [inline, static, private]

Definition at line 445 of file K3dMath.h.

References TWO_PI.

Referenced by FastTan0(), and FastTan1().

static bool K3dMath::IsOddNumber ( int  i  )  [inline, static]

Definition at line 52 of file K3dMath.h.

float K3dMath::ACos ( const float  fValue  )  [inline, static]

Wrappers to hide implementations of functions. The ACos and ASin functions clamp the input argument to [-1,1] to avoid NaN issues when the input is slightly larger than 1 or slightly smaller than -1. Other functions have the potential for using a fast and approximate algorithm rather than calling the standard math library functions.

Definition at line 161 of file K3dMath.h.

References K_PI.

Referenced by K3dVector3Work::Angle(), K3dVector3Work::AngleBetweenNormals(), K3dQuaternion::Log(), K3dQuaternion::Slerp(), K3dQuaternion::SlerpExtraSpins(), and K3dQuaternion::ToAxisAngle().

float K3dMath::ASin ( const float  fValue  )  [inline, static]

Definition at line 176 of file K3dMath.h.

References HALF_PI.

float K3dMath::ATan ( const float  fValue  )  [inline, static]

Definition at line 191 of file K3dMath.h.

Referenced by K3dAim::CalcAimRayAverage().

float K3dMath::ATan2 ( const float  fY,
const float  fX 
) [inline, static]

Definition at line 196 of file K3dMath.h.

float K3dMath::Ceil ( const float  fValue  )  [inline, static]

Definition at line 201 of file K3dMath.h.

float K3dMath::Cos ( const float  fValue  )  [inline, static]

Definition at line 206 of file K3dMath.h.

Referenced by K3dQuaternion::Exp(), and K3dQuaternion::FromAxisAngle().

float K3dMath::Exp ( const float  fValue  )  [inline, static]

Definition at line 211 of file K3dMath.h.

float K3dMath::FAbs ( const float  fValue  )  [inline, static]

Definition at line 216 of file K3dMath.h.

Referenced by K3dQuaternion::Exp(), K3dQuaternion::Log(), K3dQuaternion::Slerp(), and K3dQuaternion::SlerpExtraSpins().

float K3dMath::Floor ( const float  fValue  )  [inline, static]

Definition at line 221 of file K3dMath.h.

float K3dMath::FMod ( const float  fX,
const float  fY 
) [inline, static]

Definition at line 226 of file K3dMath.h.

float K3dMath::InvSqrt ( const float  fValue  )  [inline, static]

Definition at line 231 of file K3dMath.h.

Referenced by K3dQuaternion::ToAxisAngle().

float K3dMath::Log ( const float  fValue  )  [inline, static]

Definition at line 236 of file K3dMath.h.

float K3dMath::Pow ( const float  fBase,
const float  fExponent 
) [inline, static]

Definition at line 241 of file K3dMath.h.

float K3dMath::Sin ( const float  fValue  )  [inline, static]

Definition at line 246 of file K3dMath.h.

Referenced by K3dQuaternion::Exp(), K3dQuaternion::FromAxisAngle(), K3dQuaternion::Log(), K3dQuaternion::Slerp(), and K3dQuaternion::SlerpExtraSpins().

float K3dMath::Sqr ( const float  fValue  )  [inline, static]

Definition at line 251 of file K3dMath.h.

float K3dMath::Sqrt ( const float  fValue  )  [inline, static]

Definition at line 256 of file K3dMath.h.

Referenced by K3dQuaternion::Exp(), and K3dQuaternion::FromRotationMatrix().

float K3dMath::Tan ( const float  fValue  )  [inline, static]

Definition at line 261 of file K3dMath.h.

int K3dMath::Sign ( const int  iValue  )  [inline, static]

Return -1 if the input is negative, 0 if the input is zero, and +1 if the input is positive.

Definition at line 266 of file K3dMath.h.

Referenced by K3dDistance::DistLinePlane(), K3dIntrLinePlane::LinePlane(), and K3dIntersection::RayPlane().

int K3dMath::Sign ( const float  fValue  )  [inline, static]

Definition at line 277 of file K3dMath.h.

float K3dMath::FastSin0 ( const float  fAngle  )  [inline, static]

Fast evaluation of sin(angle) by polynomial approximations. The angle must be in [0,pi/2]. The maximum absolute error is about 1.7e-04 for FastSin0 and about 2.3e-09 for FastSin1. The speed up is about 2 for FastSin0 and about 1.5 for FastSin1.

Definition at line 479 of file K3dMath.h.

References ConvertHalfPiSin(), and HALF_PI.

float K3dMath::FastSin1 ( const float  fAngle  )  [inline, static]

Definition at line 511 of file K3dMath.h.

References ConvertHalfPiSin(), and HALF_PI.

Referenced by FastTan0(), and FastTan1().

float K3dMath::FastCos0 ( const float  fAngle  )  [inline, static]

Fast evaluation of cos(angle) by polynomial approximations. The angle must be in [0,pi/2]. The maximum absolute error is about 1.2e-03 for FastCos0 and about 2.3e-09 for FastCos1. The speed up is about 2 for FastCos0 and about 1.5 for FastCos1.

Definition at line 549 of file K3dMath.h.

References ConvertHalfPiCos(), and HALF_PI.

float K3dMath::FastCos1 ( const float  fAngle  )  [inline, static]

Definition at line 581 of file K3dMath.h.

References ConvertHalfPiCos(), and HALF_PI.

Referenced by FastTan0(), and FastTan1().

float K3dMath::FastTan0 ( const float  fAngle  )  [inline, static]

Fast evaluation of tan(angle) by polynomial approximations. The angle must be in [0,pi/4]. The maximum absolute error is about 8.1e-04 for FastTan0 and about 1.9e-08 for FastTan1. The speed up is about 2.5 for FastTan0 and about 1.75 for FastTan1.

Definition at line 617 of file K3dMath.h.

References ConvertTwoPi(), FastCos1(), FastSin1(), QUARTER_PI, and TWO_PI.

float K3dMath::FastTan1 ( const float  fAngle  )  [inline, static]

Definition at line 660 of file K3dMath.h.

References ConvertTwoPi(), FastCos1(), FastSin1(), QUARTER_PI, and TWO_PI.

float K3dMath::FastASin ( const float  fValue  )  [inline, static]

Fast evaluation of asin(value) by a sqrt times a polynomial. The value must be in [-1,1]. The maximum absolute error is about 6.8e-05 and the speed up is about 2.5.

Definition at line 711 of file K3dMath.h.

References HALF_PI.

float K3dMath::FastACos ( const float  fValue  )  [inline, static]

Fast evaluation of acos(value) by a sqrt times a polynomial. The value must be in [-1,1]. The maximum absolute error is about 6.8e-05 and the speed up is about 2.5.

Definition at line 742 of file K3dMath.h.

References K_PI.

float K3dMath::FastATan0 ( const float  fValue  )  [inline, static]

Fast evaluation of atan(value) by polynomial approximations. The value must be in [-1,1]. The maximum absolute error is about 1.2e-05 for FastInvTan0 and about 1.43-08 for FastInvTan1. The speed up is about 2.2 for FastInvTan0 and about 1.5 for FastInvTan1.

Definition at line 775 of file K3dMath.h.

References HALF_PI.

float K3dMath::FastATan1 ( const float  fValue  )  [inline, static]

Definition at line 819 of file K3dMath.h.

References HALF_PI.

float K3dMath::UnitRandom ( const float  fSeed = (float) 0.0  )  [inline, static]

Generate a random number in [0,1). The random number generator may be seeded by a first call to UnitRandom with a positive seed.

Definition at line 869 of file K3dMath.h.

float K3dMath::SymmetricRandom ( const float  fSeed = (float) 0.0  )  [inline, static]

Generate a random number in [-1,1). The random number generator may be seeded by a first call to SymmetricRandom with a positive seed.

Definition at line 878 of file K3dMath.h.

float K3dMath::IntervalRandom ( const float  fMin,
const float  fMax,
const float  fSeed = (float) 0.0 
) [inline, static]

Generate a random number in [min,max). The random number generator may be seeded by a first call to IntervalRandom with a positive seed.

Definition at line 887 of file K3dMath.h.

float K3dMath::Positive ( const float  fValue  )  [inline, static]

If value negative change to the positive.

Definition at line 896 of file K3dMath.h.

Referenced by K3dVorBsp::CheckWeight(), and K3dVector3Work::EqualRange().

int K3dMath::Positive ( const int  iValue  )  [inline, static]

If value negative change to the positive.

Definition at line 906 of file K3dMath.h.

float K3dMath::Negative ( const float  fValue  )  [inline, static]

If value positive change to the negative.

Definition at line 917 of file K3dMath.h.

int K3dMath::Negative ( const int  iValue  )  [inline, static]

If value positive change to the negative.

Definition at line 928 of file K3dMath.h.

bool K3dMath::EqualRange ( const float  _f0,
const float  _f1,
const float  _fRange 
) [static]

Is equal two values by range ?

Parameters:
_f0 First value
_f1 Second value
_fRange Equal range
Return values:
bool True if first and second value are equal by range

Definition at line 47 of file K3dMath.cpp.

Referenced by K3dVector3Obj::operator==(), and K3dVector3::operator==().


Member Data Documentation

const float K3dMath::EPSILON [static]

Common constants.

Definition at line 144 of file K3dMath.h.

Referenced by K3dQuaternion::Exp(), K3dQuaternion::Log(), K3dQuaternion::Slerp(), K3dQuaternion::SlerpExtraSpins(), and K3dQuaternion::ToAxisAngle().

const float K3dMath::MAX_REAL [static]

Definition at line 145 of file K3dMath.h.

Referenced by K3dQuaternion::operator/(), and K3dQuaternion::operator/=().

const float K3dMath::K_PI [static]

Definition at line 146 of file K3dMath.h.

Referenced by ACos(), ConvertHalfPiCos(), ConvertHalfPiSin(), FastACos(), and K3dQuaternion::SlerpExtraSpins().

const float K3dMath::TWO_PI [static]

Definition at line 147 of file K3dMath.h.

Referenced by ConvertHalfPiCos(), ConvertHalfPiSin(), ConvertTwoPi(), FastTan0(), and FastTan1().

const float K3dMath::HALF_PI [static]

Definition at line 148 of file K3dMath.h.

Referenced by ASin(), ConvertHalfPiCos(), ConvertHalfPiSin(), FastASin(), FastATan0(), FastATan1(), FastCos0(), FastCos1(), FastSin0(), and FastSin1().

const float K3dMath::QUARTER_PI [static]

Definition at line 149 of file K3dMath.h.

Referenced by FastTan0(), and FastTan1().

const float K3dMath::THREE_HALF_PI [static]

Definition at line 150 of file K3dMath.h.

Referenced by ConvertHalfPiCos(), and ConvertHalfPiSin().

const float K3dMath::INV_PI [static]

Definition at line 151 of file K3dMath.h.

const float K3dMath::INV_TWO_PI [static]

Definition at line 152 of file K3dMath.h.

const float K3dMath::K_DEG_TO_RAD [static]

Definition at line 153 of file K3dMath.h.

Referenced by K3dSphereMove::Rotate().

const float K3dMath::K_RAD_TO_DEG [static]

Definition at line 154 of file K3dMath.h.

Referenced by K3dVector3Work::AngleBetweenVectors().

const float K3dMath::K_FI [static]

Fibonacci traditional value (Golden ratio).

Definition at line 155 of file K3dMath.h.

Referenced by K3dCamera::RestrictCamView().


The documentation for this class was generated from the following files:
Generated on Thu Aug 16 23:53:32 2007 for K3dEngine by  doxygen 1.5.0