Common Mathematical Functions

Namespace: BALL::Maths More...

Functions

template<typename T >
T BALL::Maths::abs (const T &t)
Return the absolute value of a number.
template<typename T >
T BALL::Maths::frac (const T &t)
Return the fraction of a number.
template<typename T >
T BALL::Maths::max (const T &a, const T &b)
Return the greater of two numbers.
template<typename T >
T BALL::Maths::max (const T &a, const T &b, const T &ct)
Return the greatest of three numbers.
template<typename T >
T BALL::Maths::min (const T &a, const T &b)
Return the smallest of two numbers.
template<typename T >
T BALL::Maths::min (const T &a, const T &b, const T &ct)
Return the smallest of three numbers.
template<typename T >
T BALL::Maths::round (const T &t)
Round a number and return the result.
template<typename T >
T BALL::Maths::sgn (const T &t)
Return the sign of a number.
template<typename T >
bool BALL::Maths::isFinite (const T &t)
Test whether a number is finite.
template<typename T >
bool BALL::Maths::isNan (const T &t)
Test whether a value is not a number.
template<typename T >
bool BALL::Maths::isInfinite (const T &t)
Test whether a number is infinite.
template<typename T >
bool BALL::Maths::isZero (const T &t)
Test whether a number is zero.
template<typename T >
bool BALL::Maths::isNotZero (const T &t)
Test whether a number is not zero.
template<typename T1 , typename T2 >
bool BALL::Maths::isEqual (const T1 &a, const T2 &b)
Test whether a number is equal to another.
template<typename T1 , typename T2 >
bool BALL::Maths::isNotEqual (const T1 &a, const T2 &b)
Test whether a number is not equal to another.
template<typename T1 , typename T2 >
bool BALL::Maths::isLess (const T1 &a, const T2 &b)
Test whether a number is less compared to another.
template<typename T1 , typename T2 >
bool BALL::Maths::isLessOrEqual (const T1 &a, const T2 &b)
Test whether a number is less or equal compared to another.
template<typename T1 , typename T2 >
bool BALL::Maths::isGreaterOrEqual (const T1 &a, const T2 &b)
Test whether a number is greater or equal compared to another.
template<typename T1 , typename T2 >
bool BALL::Maths::isGreater (const T1 &a, const T2 &b)
Test whether a number is greater compared to another.
template<typename T >
long BALL::Maths::floor (const T &t)
Return the floor of a number.
template<typename T >
long BALL::Maths::ceiling (const T &t)
Return the ceiling of a number.
template<typename T1 , typename T2 >
Index BALL::Maths::compare (const T1 &a, const T2 &b)
Compare two numbers to each other.
template<typename T >
bool BALL::Maths::isNear (const T &a, const T &b, const T &max_diff)
Test whether two numbers are close to each other.
double BALL::Maths::rint (double x)
round to integral value in floating-point format

Detailed Description

Namespace: BALL::Maths

Function Documentation

template<typename T >
T BALL::Maths::abs ( const T & t )

template<typename T >
long BALL::Maths::ceiling ( const T & t )

Return the ceiling of a number.

Parameters:
t the number
Returns:
T the ceiling

References BALL::Maths::isEqual(), and BALL::Maths::isLess().

template<typename T1 , typename T2 >
Index BALL::Maths::compare ( const T1 & a,
const T2 & b
)

Compare two numbers to each other.

Parameters:
a the first number
b the second number
Returns:
Index -1 a < b; 0 a = b; 1 a > b

References BALL::Maths::isEqual(), and BALL::Maths::isLess().

template<typename T >
long BALL::Maths::floor ( const T & t )

template<typename T >
T BALL::Maths::frac ( const T & t )

Return the fraction of a number.

Parameters:
t the number
Returns:
T the fraction

template<typename T1 , typename T2 >
bool BALL::Maths::isEqual ( const T1 & a,
const T2 & b
)

template<typename T >
bool BALL::Maths::isFinite ( const T & t )

Test whether a number is finite.

Parameters:
t the number
Returns:
bool, true if t is finite

Referenced by BALL::Maths::isInfinite().

template<typename T1 , typename T2 >
bool BALL::Maths::isGreater ( const T1 & a,
const T2 & b
)

Test whether a number is greater compared to another.

Parameters:
a the first number
b the second number
Returns:
bool, true if a is greater than b

References BALL::Constants::EPSILON.

Referenced by BALL::Maths::floor(), BALL::GetIntersection(), BALL::TAngle< T >::normalize(), and BALL::TAngle< T >::operator>().

template<typename T1 , typename T2 >
bool BALL::Maths::isGreaterOrEqual ( const T1 & a,
const T2 & b
)

Test whether a number is greater or equal compared to another.

Parameters:
a the first number
b the second number
Returns:
bool, true if a is greater or equal than b

References BALL::Constants::EPSILON.

Referenced by BALL::GetIntersection(), and BALL::TAngle< T >::operator>=().

template<typename T >
bool BALL::Maths::isInfinite ( const T & t )

Test whether a number is infinite.

Parameters:
t the number
Returns:
bool, true if t equals inf or -inf

References BALL::Maths::isFinite(), and BALL::Maths::isNan().

template<typename T1 , typename T2 >
bool BALL::Maths::isLess ( const T1 & a,
const T2 & b
)

template<typename T1 , typename T2 >
bool BALL::Maths::isLessOrEqual ( const T1 & a,
const T2 & b
)

Test whether a number is less or equal compared to another.

Parameters:
a the first number
b the second number
Returns:
bool, true if a is less or equal b

References BALL::Constants::EPSILON.

Referenced by BALL::TSphere3< float >::has(), BALL::TCircle3< float >::has(), and BALL::TAngle< T >::operator<=().

template<typename T >
bool BALL::Maths::isNan ( const T & t )

Test whether a value is not a number.

Parameters:
t the number
Returns:
bool, true if t equals nan

Referenced by BALL::Maths::isInfinite(), and BALL::SolveSystem().

template<typename T >
bool BALL::Maths::isNear ( const T & a,
const T & b,
const T & max_diff
)

Test whether two numbers are close to each other.

Parameters:
a the first number
b the second number
max_diff the maximum allowed difference between the two numbers
Returns:
bool, true if the absolute distance between a and b is below max_diff

References BALL::Maths::abs().

template<typename T1 , typename T2 >
bool BALL::Maths::isNotEqual ( const T1 & a,
const T2 & b
)

Test whether a number is not equal to another.

Parameters:
a the first number
b the second number
Returns:
bool, true if the absolute distance of a and b is at least Constants::EPSILON

References BALL::Maths::abs(), and BALL::Constants::EPSILON.

Referenced by BALL::GetIntersection(), BALL::TVector4< T >::operator!=(), BALL::TVector3< T >::operator!=(), BALL::TVector2< T >::operator!=(), BALL::TSphere3< float >::operator!=(), BALL::TCircle3< float >::operator!=(), and BALL::TAngle< T >::operator!=().

template<typename T >
bool BALL::Maths::isNotZero ( const T & t )

Test whether a number is not zero.

Parameters:
t the number
Returns:
bool, true, if the absolute value of t is at least Constants::EPSILON

References BALL::Maths::abs(), and BALL::Constants::EPSILON.

Referenced by BALL::GetDistance(), and BALL::TLine3< T >::has().

template<typename T >
bool BALL::Maths::isZero ( const T & t )

template<typename T >
T BALL::Maths::max ( const T & a,
const T & b,
const T & ct
)

template<typename T >
T BALL::Maths::max ( const T & a,
const T & b
)

Return the greater of two numbers.

Parameters:
a the first number
b the second number
Returns:
T the greatest number

template<typename T >
T BALL::Maths::min ( const T & a,
const T & b,
const T & ct
)

template<typename T >
T BALL::Maths::min ( const T & a,
const T & b
)

Return the smallest of two numbers.

Parameters:
a the first number
b the second number
Returns:
T the smallest number

template<typename T >
T BALL::Maths::round ( const T & t )

Round a number and return the result.

Parameters:
t the number
Returns:
T the result

template<typename T >
T BALL::Maths::sgn ( const T & t )

Return the sign of a number.

Parameters:
t the number
Returns:
Index -1 t < 0; 0 t = 0; 1 t > 0

Generated on Thu Aug 6 18:30:00 2009 for BALL by doxygen 1.5.8