SbMathHelper Namespace Reference

Functions

SbBool floatIsEqual (float A, float B, unsigned int numFloat)
template<typename T >
Max (T a, T b)
template<typename T >
Min (T a, T b)
template<typename T >
shiftValue (T v, int offset)
template<>
float shiftValue (float v, int offset)
template<>
double shiftValue (double v, int offset)
template<typename T >
Clamp (T a, T minV, T maxV)
template<typename T >
alignToNextPowerOf2 (T n, size_t shift)
template<typename T >
getNextPow2 (T a)
template<int N, typename T >
nearestUpperMultipleOf (T v)
template<int N, typename T >
nearestLowerMultipleOf (T v)
int getNextLog2 (int num)
float deg2Rad (float a)
float rad2Deg (float a)
bool isNaN (double a)
int rand ()
void srand (unsigned seed)
template<typename T >
bool isCoinc (const T &x, const T &y, T tol=(T) OIV_DEF_MATH_HELPER_EPS)
template<typename T >
abs (const T &v)
template<>
long int abs (const long int &v)
template<>
float abs (const float &v)
template<>
double abs (const double &v)
template<typename T >
bool isLessThan (const T &x, const T &y, T tol=(T) OIV_DEF_MATH_HELPER_EPS)
template<typename T >
bool isGreaterThan (const T &x, const T &y, T tol=(T) OIV_DEF_MATH_HELPER_EPS)
template<typename T >
bool isLessOrEqualThan (const T &x, const T &y, T tol=(T) OIV_DEF_MATH_HELPER_EPS)
template<typename T >
bool isGreaterOrEqualThan (const T &x, const T &y, T tol=(T) OIV_DEF_MATH_HELPER_EPS)
template<typename T >
bool checkRangeI (const T &x, const T &min, T max, T tol=(T) OIV_DEF_MATH_HELPER_EPS)
template<typename T >
bool checkRangeE (const T &x, const T &min, T max, T tol=(T) OIV_DEF_MATH_HELPER_EPS)
template<typename T >
bool isCoincRelativeOrAbsolute (const T &A, const T &B, T maxRelativeError, T maxAbsoluteError)
template<typename T >
int sgn (const T &val)
template<typename T >
rangeMax ()
template<typename T >
rangeMin ()
template<>
float rangeMin< float > ()
template<>
double rangeMin< double > ()
template<typename T >
fract (const T &value)
template<>
float fract (const float &value)
template<>
double fract (const double &value)
template<>
long double fract (const long double &value)

Variables

static const int OIV_RAND_MAX = 32767
static const float OIV_DEF_MATH_HELPER_EPS = 1.e-6f



bool isFinite (double value)
bool isFinite (float value)

Function Documentation

template<>
double SbMathHelper::abs ( const double &  v  )  [inline]
template<>
float SbMathHelper::abs ( const float &  v  )  [inline]
template<>
long int SbMathHelper::abs ( const long int &  v  )  [inline]
template<typename T >
T SbMathHelper::abs ( const T &  v  )  [inline]

Return absolute value of v.

template<typename T >
T SbMathHelper::alignToNextPowerOf2 ( n,
size_t  shift 
) [inline]

Return an integer multiple of 2^shift greater or equals to n.

template<typename T >
bool SbMathHelper::checkRangeE ( const T &  x,
const T &  min,
max,
tol = (T)OIV_DEF_MATH_HELPER_EPS 
) [inline]

Inside open interval (excluding endpoints) using given tolerance test.

template<typename T >
bool SbMathHelper::checkRangeI ( const T &  x,
const T &  min,
max,
tol = (T)OIV_DEF_MATH_HELPER_EPS 
) [inline]

Inside closed interval (including endpoints) using given tolerance test.

template<typename T >
T SbMathHelper::Clamp ( a,
minV,
maxV 
) [inline]

Clamps value to given range [minV, maxV].

float SbMathHelper::deg2Rad ( float  a  )  [inline]

Convert degrees to radians.

SbBool SbMathHelper::floatIsEqual ( float  A,
float  B,
unsigned int  numFloat 
)

Return true if A and B are equal.

numFloat is the number of allowed representable IEEE float between A and B. For example, there is no number between 10000 and 10000.000977. So if numFloat=1 it will return true for these two numbers.

template<>
long double SbMathHelper::fract ( const long double &  value  )  [inline]
template<>
double SbMathHelper::fract ( const double &  value  )  [inline]
template<>
float SbMathHelper::fract ( const float &  value  )  [inline]
template<typename T >
T SbMathHelper::fract ( const T &  value  )  [inline]

Return fractional part of given value.

ex: fract(23.15) return 0.15

int SbMathHelper::getNextLog2 ( int  num  ) 

Return the next log of 2 greater or equal to a.

template<typename T >
T SbMathHelper::getNextPow2 ( a  )  [inline]

Return the next power of 2 greater or equal to a.

template<typename T >
bool SbMathHelper::isCoinc ( const T &  x,
const T &  y,
tol = (T)OIV_DEF_MATH_HELPER_EPS 
) [inline]

Coincidence test using given tolerance.

template<typename T >
bool SbMathHelper::isCoincRelativeOrAbsolute ( const T &  A,
const T &  B,
maxRelativeError,
maxAbsoluteError 
) [inline]

Relative error comparison.

bool SbMathHelper::isFinite ( float  value  )  [inline]

Returns true if the value is a finite value (i.e.

is is normal, subnormal or zero but not infinite or NaN).

bool SbMathHelper::isFinite ( double  value  )  [inline]

Returns true if the value is a finite value (i.e.

is is normal, subnormal or zero but not infinite or NaN).

template<typename T >
bool SbMathHelper::isGreaterOrEqualThan ( const T &  x,
const T &  y,
tol = (T)OIV_DEF_MATH_HELPER_EPS 
) [inline]

Greater or equal than test (x >= y) using given tolerance.

template<typename T >
bool SbMathHelper::isGreaterThan ( const T &  x,
const T &  y,
tol = (T)OIV_DEF_MATH_HELPER_EPS 
) [inline]

Greater than test (x > y) using given tolerance.

template<typename T >
bool SbMathHelper::isLessOrEqualThan ( const T &  x,
const T &  y,
tol = (T)OIV_DEF_MATH_HELPER_EPS 
) [inline]

Less or equal than test (x <= y) using given tolerance.

template<typename T >
bool SbMathHelper::isLessThan ( const T &  x,
const T &  y,
tol = (T)OIV_DEF_MATH_HELPER_EPS 
) [inline]

Less than test (x < y) using given tolerance.

bool SbMathHelper::isNaN ( double  a  )  [inline]

Returns true if the specified value is NaN.

template<typename T >
T SbMathHelper::Max ( a,
b 
) [inline]
template<typename T >
T SbMathHelper::Min ( a,
b 
) [inline]
template<int N, typename T >
T SbMathHelper::nearestLowerMultipleOf ( v  )  [inline]

Return the nearest lower multiple of some value.

for example nearestLowerMultipleOf<4>(7) return 4. Template because it let compiler to do some optimizations.

template<int N, typename T >
T SbMathHelper::nearestUpperMultipleOf ( v  )  [inline]

Return the nearest upper multiple of some value.

for example nearestUpperMultipleOf<4>(7) return 8. Template because it let compiler to do some optimizations.

float SbMathHelper::rad2Deg ( float  a  )  [inline]

Convert radians to degrees.

int SbMathHelper::rand (  ) 

Returns a pseudo-random integer between 0 and OIV_RAND_MAX.

The returned sequence will be the same on all machines.

template<typename T >
T SbMathHelper::rangeMax (  )  [inline]

Returns the maximum finite value representable by the numeric type T.

template<typename T >
T SbMathHelper::rangeMin (  )  [inline]

Returns the lowest finite value representable by the numeric type T, that is, a finite value x such that there is no other finite value y where y < x.

template<>
double SbMathHelper::rangeMin< double > (  )  [inline]
template<>
float SbMathHelper::rangeMin< float > (  )  [inline]
template<typename T >
int SbMathHelper::sgn ( const T &  val  )  [inline]

Implements signum return value in { -1, 0, +1 }.

template<>
double SbMathHelper::shiftValue ( double  v,
int  offset 
) [inline]
template<>
float SbMathHelper::shiftValue ( float  v,
int  offset 
) [inline]
template<typename T >
T SbMathHelper::shiftValue ( v,
int  offset 
) [inline]

shift the value of offset representable values considering value type.

If T is an integer type (char, short, etc...), it just return v + offset. If T is a float type (float, double, ...) it return the offset'th representable value starting from v. ex: shiftValue(10000.0f, 1) returns 10000.000977...

void SbMathHelper::srand ( unsigned  seed  ) 

Set seed for a new sequence of pseudo-random integers to be returned by rand().


Variable Documentation

const float SbMathHelper::OIV_DEF_MATH_HELPER_EPS = 1.e-6f [static]

Default epsilon value for coincidence and interval checking.

const int SbMathHelper::OIV_RAND_MAX = 32767 [static]

Maximum value returned by SbMathHelper::rand().


Open Inventor by FEI reference manual, generated on 19 Aug 2019
Copyright © FEI S.A.S. All rights reserved.
http://www.openinventor.com/