file REDMath.h
RED math functions header file. More...
Go to the source code of this file.
Namespaces:
namespace | RED |
Functions:
template< typename T > const T & | REDClamp ( const T & a, const T & min, const T & max ) |
unsigned short | REDDoubleToHalf ( double iDouble ) |
int | REDFastFloor ( double iValue ) |
REDExp unsigned short | REDFloatToHalf ( float iFloat ) |
double | REDFract ( double iValue ) |
REDExp float | REDHalfToFloat ( unsigned short iHalfFloat ) |
double | REDLerp ( double t, double a, double b ) |
double | REDLog2 ( 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 ) |
double | REDMISPower ( double pdf_a, double pdf_b ) |
int | REDPositiveMod ( int iValue, int iModulo ) |
Defines:
#define | RED_HALF_MINUS_ONE ( 0xbc00 ) |
#define | RED_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:
unsigned short REDDoubleToHalf | ( | double | iDouble | ) |
Converts a value from double to half-float format.
Parameters:
iDouble: | value in double format (64 bits). |
Returns:
int REDFastFloor | ( | double | iValue | ) |
Computes the floor of a value.
Parameters:
iValue: | input value. |
Returns:
REDExp unsigned short REDFloatToHalf | ( | float | iFloat | ) |
Converts a value from float to half-float format.
Parameters:
iFloat: | value in float format (32 bits). |
Returns:
double REDFract | ( | double | iValue | ) |
Computes the fractional part of a value.
Parameters:
iValue: | input value. |
Returns:
REDExp float REDHalfToFloat | ( | unsigned short | iHalfFloat | ) |
Converts a value from half-float to float format.
Parameters:
iHalfFloat: | value in half-float format (16 bits). |
Returns:
double REDLerp | ( | double | t, |
double | a, | ||
double | b | ||
) |
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 | ( | double | iValue | ) |
Computes the base-2 logarithm of a value.
Parameters:
iValue: | input value. |
Returns:
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:
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:
double REDMISPower | ( | double | pdf_a, |
double | pdf_b | ||
) |
int REDPositiveMod | ( | int | iValue, |
int | iModulo | ||
) |
Computes the positive modulo of a value.
Parameters:
iValue: | input value. |
iModulo: | modulo value. |
Returns:
Defines documentation
Unsigned short value encoding -1.0f.
Unsigned short value encoding 1.0f.