file REDMath.h

RED math functions header file. More...

Go to the source code of this file.

Namespaces:

namespaceRED

Functions:

template< typename T > const T &REDClamp ( const T & a, const T & min, const T & max )
unsigned shortREDDoubleToHalf ( double iDouble )
intREDFastFloor ( double iValue )
REDExp unsigned shortREDFloatToHalf ( float iFloat )
doubleREDFract ( double iValue )
REDExp floatREDHalfToFloat ( unsigned short iHalfFloat )
doubleREDLerp ( double t, double a, double b )
doubleREDLog2 ( double iValue )
template< typename T > const T &REDMax ( const T & a, const T & b )
template< typename T > const T &REDMin ( const T & a, const T & b )
doubleREDMISPower ( double pdf_a, double pdf_b )
intREDPositiveMod ( int iValue, int iModulo )

Defines:

#defineRED_HALF_MINUS_ONE ( 0xbc00 )
#defineRED_HALF_ONE ( 0x3c00 )

Detailed description:

RED math functions header file.

This file contains implementations of frequently used mathematic functions like min/max, conversions between math types...

Functions documentation

template< typename T > const T & REDClamp(const T &a,
const T &min,
const T &max
)

Clamps the value two external boundaries.

If a is lower than min, then the function returns min. If a is higher than max, then the function returns max. If a is between min and max, then the function returns a.

The values class must implement the '<' operator.

Parameters:

a:first value to compare.
min:minimum value of the range.
max:maximum value of the range.

Returns:

the maximum of the two values.
unsigned short REDDoubleToHalf(doubleiDouble)

Converts a value from double to half-float format.

Parameters:

iDouble:value in double format (64 bits).

Returns:

the value converted to half-float format.
int REDFastFloor(doubleiValue)

Computes the floor of a value.

Parameters:

iValue:input value.

Returns:

the floor of a value.
REDExp unsigned short REDFloatToHalf(floatiFloat)

Converts a value from float to half-float format.

Parameters:

iFloat:value in float format (32 bits).

Returns:

the value converted to half-float format.
double REDFract(doubleiValue)

Computes the fractional part of a value.

Parameters:

iValue:input value.

Returns:

the fractional part of a value.
REDExp float REDHalfToFloat(unsigned shortiHalfFloat)

Converts a value from half-float to float format.

Parameters:

iHalfFloat:value in half-float format (16 bits).

Returns:

the value converted to float format.
double REDLerp(doublet,
doublea,
doubleb
)

Returns the linear interpolation at 't' between two given values.

Parameters:

t:a value in [0, 1].
a:first value.
b:second value.
double REDLog2(doubleiValue)

Computes the base-2 logarithm of a value.

Parameters:

iValue:input value.

Returns:

the base-2 logarithm of a value.
template< typename T > const T & REDMax(const T &a,
const T &b
)

Gets the maximum value of two values.

The values class must implement the '<' operator.

Parameters:

a:first value to compare.
b:second value to compare.

Returns:

the maximum of the two values.
template< typename T > const T & REDMin(const T &a,
const T &b
)

Gets the minimum value of two values.

The values class must implement the '<' operator.

Parameters:

a:first value to compare.
b:second value to compare.

Returns:

the minimum of the two values.
double REDMISPower(doublepdf_a,
doublepdf_b
)
int REDPositiveMod(intiValue,
intiModulo
)

Computes the positive modulo of a value.

Parameters:

iValue:input value.
iModulo:modulo value.

Returns:

the positive modulo of a value.

Defines documentation

#define RED_HALF_MINUS_ONE ( 0xbc00 )

Unsigned short value encoding -1.0f.

#define RED_HALF_ONE ( 0x3c00 )

Unsigned short value encoding 1.0f.