REDMath.h
Macro Definitions
RED_HALF_ONE |
|
RED_HALF_MINUS_ONE |
Functions
| typename T | REDMin |
| typename T | REDMax |
| typename T | REDClamp |
| double | REDLerp |
REDExp float |
REDHalfToFloat |
REDExp unsigned short |
REDFloatToHalf |
| unsigned short | REDDoubleToHalf |
| double | REDLog2 |
| double | REDFract |
| int | REDPositiveMod |
| int | REDFastFloor |
| double | REDMISPower |
Detailed Description
This file contains implementations of frequently used mathematic functions like min/max, conversions between math types…
Macro Definition
-
RED_HALF_ONE Unsigned short value encoding 1.0f.
-
RED_HALF_MINUS_ONE Unsigned short value encoding -1.0f.
Function Documentation
-
template<typename
T>
inline 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.
-
template<typename
T>
inline 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>
inline 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.
-
inline 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.
-
inline unsigned short
REDDoubleToHalf(double iDouble) 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.
-
inline double
REDLog2(double iValue) Computes the base-2 logarithm of a value.
Parameters: iValue – input value. Returns: the base-2 logarithm of a value.
-
inline double
REDFract(double iValue) Computes the fractional part of a value.
Parameters: iValue – input value. Returns: the fractional part of a value.
-
inline int
REDPositiveMod(int iValue, int iModulo) Computes the positive modulo of a value.
Parameters: - iValue – input value.
- iModulo – modulo value.
Returns: the positive modulo of a value.
-
inline int
REDFastFloor(double iValue) Computes the floor of a value.
Parameters: iValue – input value. Returns: the floor of a value.
-
inline double
REDMISPower(double pdf_a, double pdf_b)