PixelLightAPI
.
|
Static class with some useful math constants and functions. More...
#include <Math.h>
Static Public Member Functions | |
static bool | IsNotANumber (float fValue) |
Checks whether the given float-precision floating-point value is not a number (NAN) | |
static bool | IsNotANumber (double dValue) |
Checks whether the given double-precision floating-point value is not a number (NAN) | |
static bool | IsFinite (float fValue) |
Checks whether the given float-precision floating-point value is finite. | |
static bool | IsFinite (double dValue) |
Checks whether the given double-precision floating-point value is finite. | |
static bool | IsPowerOfTwo (int nNumber) |
Check's whether the given the number is a power of 2. | |
static int | GetNearestPowerOfTwo (int nNumber, bool bLower=true) |
Returns the nearest power of 2. | |
static PLCore::uint32 | GetRand () |
Returns a positive random number. | |
static int | GetRandNeg () |
Returns a positive or negative random number. | |
static float | GetRandFloat () |
Returns a positive float random number between 0..1. | |
static float | GetRandNegFloat () |
Returns a positive or negative float random number between -1..1. | |
static float | GetRandMinMaxFloat (float fMin, float fMax) |
Returns a float random number between the given minimum/maximum. | |
static bool | AreEqual (float f1, float f2, float fEpsilon=Math::Epsilon) |
Returns a whether to given numbers are equal or not. | |
static bool | AreEqual (double d1, double d2, double dEpsilon=Math::Epsilon) |
Returns a whether to given numbers are equal or not. | |
static float | Min (float a, float b) |
Returns the minimum of the 2 given values. | |
static int | Min (int a, int b) |
static PLCore::uint32 | Min (PLCore::uint32 a, PLCore::uint32 b) |
static float | Max (float a, float b) |
Returns the maximum of the 2 given values. | |
static int | Max (int a, int b) |
static PLCore::uint32 | Max (PLCore::uint32 a, PLCore::uint32 b) |
static float | Min (float a, float b, float c, float d) |
Returns the minimum of the 4 given values. | |
static int | Min (int a, int b, int c, int d) |
static PLCore::uint32 | Min (PLCore::uint32 a, PLCore::uint32 b, PLCore::uint32 c, PLCore::uint32 d) |
static float | Max (float a, float b, float c, float d) |
Returns the maximum of the 4 given values. | |
static int | Max (int a, int b, int c, int d) |
static PLCore::uint32 | Max (PLCore::uint32 a, PLCore::uint32 b, PLCore::uint32 c, PLCore::uint32 d) |
static float | Sign (float x) |
Returns the sign of the given value. | |
static float | ClampToInterval (float fValue, float fMin, float fMax) |
Ensures that the given value is within the given interval [fMin, fMax] by clamping the value. | |
static float | WrapToInterval (float fValue, float fMin, float fMax) |
Ensures that the given value is within the given interval [fMin, fMax] by wrapping the value. | |
static int | Abs (int x) |
Returns the absolute value of the given value. | |
static float | Abs (float x) |
Returns the absolute value of the given value. | |
static double | Abs (double x) |
Returns the absolute value of the given value. | |
static void | Swap (float &a, float &b) |
Swaps two given values. | |
static float | Saturate (float fValue) |
Clamps the value between 0.0 and 1.0. | |
static float | Floor (float fValue) |
Returns the floor of the given value. | |
static float | Ceil (float fValue) |
Returns the ceil of the given value. | |
static float | Round (float fValue, PLCore::uint32 nPrecision=0) |
Returns the rounded value of the given value. | |
static float | Sin (float fAngle) |
Returns the sine of a given angle. | |
static double | Sin (double dAngle) |
Returns the sine of a given angle. | |
static float | ASin (float fValue) |
Returns the arcsine of a given value. | |
static double | ASin (double dValue) |
Returns the arcsine of a given value. | |
static float | Cos (float fAngle) |
Returns the cosine (cos) of a given angle. | |
static double | Cos (double dAngle) |
Returns the cosine (cos) of a given angle. | |
static float | ACos (float fValue) |
Returns the arccosine of a given value. | |
static double | ACos (double dValue) |
Returns the arccosine of a given value. | |
static float | Tan (float fAngle) |
Returns the tangent (tan) of a given angle. | |
static double | Tan (double dAngle) |
Returns the tangent (tan) of a given angle. | |
static float | ATan (float fValue) |
Returns the arctangent of a given value. | |
static double | ATan (double dValue) |
Returns the arctangent of a given value. | |
static float | ATan2 (float fX, float fY) |
Returns the arctangent of of y/x. | |
static double | ATan2 (double dX, double dY) |
Returns the arctangent of of y/x. | |
static float | Sqrt (float fValue) |
Returns the square-root of a given value. | |
static double | Sqrt (double dValue) |
Returns the square-root of a given value. | |
static float | FastInvSqrt (float fValue) |
Returns the inverse square-root of a given value. | |
static float | Pow (float x, float y) |
Returns x raised to the power of y. | |
static double | Pow (double x, double y) |
Returns x raised to the power of y. | |
static double | Pow (int x, int y) |
Returns x raised to the power of y. | |
static float | Log (float x) |
Returns the natural logarithm of a given number. | |
static double | Log (double x) |
Returns the natural logarithm of a given number. | |
static float | Log2 (float x) |
Returns the base 2 logarithm for a given number, as long as it is not negative, or zero. | |
static double | Log2 (double x) |
Returns the base 2 logarithm for a given number, as long as it is not negative, or zero. | |
static float | Exp (float x) |
Returns the e number raised to the power x. | |
static double | Exp (double x) |
Returns the e number raised to the power x. | |
Static Public Attributes | |
static PLMATH_API const double | Pi |
static PLMATH_API const double | Pi2 |
static PLMATH_API const double | PiHalf |
static PLMATH_API const double | DegToRad |
static PLMATH_API const double | RadToDeg |
static PLMATH_API const double | Epsilon |
static PLMATH_API const double | Log2Const |
static PLMATH_API const int | RandMax |
Static class with some useful math constants and functions.
bool PLMath::Math::IsNotANumber | ( | float | fValue | ) | [inline, static] |
Checks whether the given float-precision floating-point value is not a number (NAN)
bool PLMath::Math::IsNotANumber | ( | double | dValue | ) | [inline, static] |
Checks whether the given double-precision floating-point value is not a number (NAN)
bool PLMath::Math::IsFinite | ( | float | fValue | ) | [inline, static] |
Checks whether the given float-precision floating-point value is finite.
bool PLMath::Math::IsFinite | ( | double | dValue | ) | [inline, static] |
Checks whether the given double-precision floating-point value is finite.
bool PLMath::Math::IsPowerOfTwo | ( | int | nNumber | ) | [inline, static] |
Check's whether the given the number is a power of 2.
[in] | nNumber | Number to check |
int PLMath::Math::GetNearestPowerOfTwo | ( | int | nNumber, |
bool | bLower = true |
||
) | [inline, static] |
Returns the nearest power of 2.
[in] | nNumber | Number to check |
[in] | bLower | 'true' take the lower nearest number, else 'false' takes the higher one |
PLCore::uint32 PLMath::Math::GetRand | ( | ) | [inline, static] |
Returns a positive random number.
int PLMath::Math::GetRandNeg | ( | ) | [inline, static] |
Returns a positive or negative random number.
float PLMath::Math::GetRandFloat | ( | ) | [inline, static] |
Returns a positive float random number between 0..1.
float PLMath::Math::GetRandNegFloat | ( | ) | [inline, static] |
Returns a positive or negative float random number between -1..1.
float PLMath::Math::GetRandMinMaxFloat | ( | float | fMin, |
float | fMax | ||
) | [inline, static] |
Returns a float random number between the given minimum/maximum.
[in] | fMin | Minimum (inclusive), must be <= maximum |
[in] | fMax | Maximum (inclusive), must be >= minimum |
bool PLMath::Math::AreEqual | ( | float | f1, |
float | f2, | ||
float | fEpsilon = Math::Epsilon |
||
) | [inline, static] |
Returns a whether to given numbers are equal or not.
[in] | f1 | First number |
[in] | f2 | Second number |
[in] | fEpsilon | Error tolerance |
bool PLMath::Math::AreEqual | ( | double | d1, |
double | d2, | ||
double | dEpsilon = Math::Epsilon |
||
) | [inline, static] |
Returns a whether to given numbers are equal or not.
[in] | d1 | First number |
[in] | d2 | Second number |
[in] | dEpsilon | Error tolerance |
float PLMath::Math::Min | ( | float | a, |
float | b | ||
) | [inline, static] |
Returns the minimum of the 2 given values.
[in] | a | First value |
[in] | b | Second value |
int PLMath::Math::Min | ( | int | a, |
int | b | ||
) | [inline, static] |
PLCore::uint32 PLMath::Math::Min | ( | PLCore::uint32 | a, |
PLCore::uint32 | b | ||
) | [inline, static] |
float PLMath::Math::Max | ( | float | a, |
float | b | ||
) | [inline, static] |
Returns the maximum of the 2 given values.
[in] | a | First value |
[in] | b | Second value |
int PLMath::Math::Max | ( | int | a, |
int | b | ||
) | [inline, static] |
PLCore::uint32 PLMath::Math::Max | ( | PLCore::uint32 | a, |
PLCore::uint32 | b | ||
) | [inline, static] |
float PLMath::Math::Min | ( | float | a, |
float | b, | ||
float | c, | ||
float | d | ||
) | [inline, static] |
Returns the minimum of the 4 given values.
[in] | a | First value |
[in] | b | Second value |
[in] | c | Third value |
[in] | d | Fourth value |
int PLMath::Math::Min | ( | int | a, |
int | b, | ||
int | c, | ||
int | d | ||
) | [inline, static] |
PLCore::uint32 PLMath::Math::Min | ( | PLCore::uint32 | a, |
PLCore::uint32 | b, | ||
PLCore::uint32 | c, | ||
PLCore::uint32 | d | ||
) | [inline, static] |
float PLMath::Math::Max | ( | float | a, |
float | b, | ||
float | c, | ||
float | d | ||
) | [inline, static] |
Returns the maximum of the 4 given values.
[in] | a | First value |
[in] | b | Second value |
[in] | c | Third value |
[in] | d | Fourth value |
int PLMath::Math::Max | ( | int | a, |
int | b, | ||
int | c, | ||
int | d | ||
) | [inline, static] |
PLCore::uint32 PLMath::Math::Max | ( | PLCore::uint32 | a, |
PLCore::uint32 | b, | ||
PLCore::uint32 | c, | ||
PLCore::uint32 | d | ||
) | [inline, static] |
float PLMath::Math::Sign | ( | float | x | ) | [inline, static] |
Returns the sign of the given value.
[in] | x | Value to check |
float PLMath::Math::ClampToInterval | ( | float | fValue, |
float | fMin, | ||
float | fMax | ||
) | [inline, static] |
Ensures that the given value is within the given interval [fMin, fMax] by clamping the value.
[in] | fValue | Value to check |
[in] | fMin | Minimum of the interval, must be < fMax! |
[in] | fMax | Maximum of the interval, must be > fMin! |
float PLMath::Math::WrapToInterval | ( | float | fValue, |
float | fMin, | ||
float | fMax | ||
) | [inline, static] |
Ensures that the given value is within the given interval [fMin, fMax] by wrapping the value.
[in] | fValue | Value to check |
[in] | fMin | Minimum of the interval, must be < fMax! |
[in] | fMax | Maximum of the interval, must be > fMin! |
int PLMath::Math::Abs | ( | int | x | ) | [inline, static] |
Returns the absolute value of the given value.
[in] | x | Value to return the absolute value from |
float PLMath::Math::Abs | ( | float | x | ) | [inline, static] |
Returns the absolute value of the given value.
[in] | x | Value to return the absolute value from |
double PLMath::Math::Abs | ( | double | x | ) | [inline, static] |
Returns the absolute value of the given value.
[in] | x | Value to return the absolute value from |
void PLMath::Math::Swap | ( | float & | a, |
float & | b | ||
) | [inline, static] |
Swaps two given values.
[in,out] | a | First value |
[in,out] | b | Second value |
float PLMath::Math::Saturate | ( | float | fValue | ) | [inline, static] |
Clamps the value between 0.0 and 1.0.
[in] | fValue | Value to clamp |
float PLMath::Math::Floor | ( | float | fValue | ) | [inline, static] |
Returns the floor of the given value.
[in] | fValue | Value to return the floor from |
float PLMath::Math::Ceil | ( | float | fValue | ) | [inline, static] |
Returns the ceil of the given value.
[in] | fValue | Value to return the ceil from |
float PLMath::Math::Round | ( | float | fValue, |
PLCore::uint32 | nPrecision = 0 |
||
) | [inline, static] |
Returns the rounded value of the given value.
[in] | fValue | Value to return the rounded value from |
[in] | nPrecision | Number of digits after the comma |
float PLMath::Math::Sin | ( | float | fAngle | ) | [inline, static] |
Returns the sine of a given angle.
Returns the sine of the given angle.
[in] | fAngle | Angle in radians |
double PLMath::Math::Sin | ( | double | dAngle | ) | [inline, static] |
Returns the sine of a given angle.
Returns the sine of the given angle.
[in] | dAngle | Angle in radians |
float PLMath::Math::ASin | ( | float | fValue | ) | [inline, static] |
Returns the arcsine of a given value.
[in] | fValue | Value between 1 and 1 whose arcsine is to be calculated |
double PLMath::Math::ASin | ( | double | dValue | ) | [inline, static] |
Returns the arcsine of a given value.
[in] | dValue | Value between 1 and 1 whose arcsine is to be calculated |
float PLMath::Math::Cos | ( | float | fAngle | ) | [inline, static] |
Returns the cosine (cos) of a given angle.
[in] | fAngle | Angle in radians |
double PLMath::Math::Cos | ( | double | dAngle | ) | [inline, static] |
Returns the cosine (cos) of a given angle.
[in] | dAngle | Angle in radians |
float PLMath::Math::ACos | ( | float | fValue | ) | [inline, static] |
Returns the arccosine of a given value.
[in] | fValue | Value between 1 and 1 whose arccosine is to be calculated |
double PLMath::Math::ACos | ( | double | dValue | ) | [inline, static] |
Returns the arccosine of a given value.
[in] | dValue | Value between 1 and 1 whose arccosine is to be calculated |
float PLMath::Math::Tan | ( | float | fAngle | ) | [inline, static] |
Returns the tangent (tan) of a given angle.
[in] | fAngle | Angle in radians |
double PLMath::Math::Tan | ( | double | dAngle | ) | [inline, static] |
Returns the tangent (tan) of a given angle.
[in] | dAngle | Angle in radians |
float PLMath::Math::ATan | ( | float | fValue | ) | [inline, static] |
Returns the arctangent of a given value.
[in] | fValue | Value between 1 and 1 whose arccosine is to be calculated |
double PLMath::Math::ATan | ( | double | dValue | ) | [inline, static] |
Returns the arctangent of a given value.
[in] | dValue | Value between 1 and 1 whose arccosine is to be calculated |
float PLMath::Math::ATan2 | ( | float | fX, |
float | fY | ||
) | [inline, static] |
Returns the arctangent of of y/x.
[in] | fX | Any number |
[in] | fY | Any number |
double PLMath::Math::ATan2 | ( | double | dX, |
double | dY | ||
) | [inline, static] |
Returns the arctangent of of y/x.
[in] | dX | Any number |
[in] | dY | Any number |
float PLMath::Math::Sqrt | ( | float | fValue | ) | [inline, static] |
Returns the square-root of a given value.
[in] | fValue | Nonnegative floating-point value, if negative, this function returns an indefinite (same as a quiet NaN) |
double PLMath::Math::Sqrt | ( | double | dValue | ) | [inline, static] |
Returns the square-root of a given value.
[in] | dValue | Nonnegative floating-point value, if negative, this function returns an indefinite (same as a quiet NaN) |
float PLMath::Math::FastInvSqrt | ( | float | fValue | ) | [inline, static] |
Returns the inverse square-root of a given value.
[in] | fValue | Nonnegative floating-point value, if negative, this function returns an indefinite (same as a quiet NaN) |
float PLMath::Math::Pow | ( | float | x, |
float | y | ||
) | [inline, static] |
Returns x raised to the power of y.
[in] | x | Base |
[in] | y | Exponent |
double PLMath::Math::Pow | ( | double | x, |
double | y | ||
) | [inline, static] |
Returns x raised to the power of y.
[in] | x | Base |
[in] | y | Exponent |
double PLMath::Math::Pow | ( | int | x, |
int | y | ||
) | [inline, static] |
Returns x raised to the power of y.
[in] | x | Base |
[in] | y | Exponent |
float PLMath::Math::Log | ( | float | x | ) | [inline, static] |
Returns the natural logarithm of a given number.
[in] | x | Given number |
double PLMath::Math::Log | ( | double | x | ) | [inline, static] |
Returns the natural logarithm of a given number.
[in] | x | Given number |
float PLMath::Math::Log2 | ( | float | x | ) | [inline, static] |
Returns the base 2 logarithm for a given number, as long as it is not negative, or zero.
[in] | x | Given number |
double PLMath::Math::Log2 | ( | double | x | ) | [inline, static] |
Returns the base 2 logarithm for a given number, as long as it is not negative, or zero.
[in] | x | Given number |
float PLMath::Math::Exp | ( | float | x | ) | [inline, static] |
Returns the e number raised to the power x.
[in] | x | Given number |
double PLMath::Math::Exp | ( | double | x | ) | [inline, static] |
Returns the e number raised to the power x.
[in] | x | Given number |
PLMATH_API const double PLMath::Math::Pi [static] |
3.14159265358979323846
PLMATH_API const double PLMath::Math::Pi2 [static] |
6.28318530717958623200 (Pi*2)
PLMATH_API const double PLMath::Math::PiHalf [static] |
1.57079632679489655800 (Pi/2)
PLMATH_API const double PLMath::Math::DegToRad [static] |
0.01745329251994329576 (Pi/180)
PLMATH_API const double PLMath::Math::RadToDeg [static] |
57.2957795130823208768 (180/Pi)
PLMATH_API const double PLMath::Math::Epsilon [static] |
1.192092896e-07F
PLMATH_API const double PLMath::Math::Log2Const [static] |
0.693147180559945309417
PLMATH_API const int PLMath::Math::RandMax [static] |
Maximum random value (0x7fff)
|