![]() |
Murl Engine API
Version 2018.3
|
Mathematic functions (Trigonometric, exponential, rounding, etc.). More...
Functions | |
template<class DataType > | |
DataType | Murl::Math::Abs (DataType value) |
Get the absolute value. More... | |
template<class DataType > | |
DataType | Murl::Math::Sgn (DataType value) |
Get the sign of a value. More... | |
template<class DataType > | |
const DataType & | Murl::Math::Min (const DataType &x, const DataType &y) |
Get the minimum of two values. More... | |
template<class DataType > | |
const DataType & | Murl::Math::Min (const DataType &x, const DataType &y, const DataType &z) |
Get the minimum of three values. More... | |
template<class DataType > | |
const DataType & | Murl::Math::Min (const DataType &x, const DataType &y, const DataType &z, const DataType &w) |
Get the minimum of four values. More... | |
template<class DataType > | |
const DataType & | Murl::Math::Max (const DataType &x, const DataType &y) |
Get the maximum of two values. More... | |
template<class DataType > | |
const DataType & | Murl::Math::Max (const DataType &x, const DataType &y, const DataType &z) |
Get the maximum of three values. More... | |
template<class DataType > | |
const DataType & | Murl::Math::Max (const DataType &x, const DataType &y, const DataType &z, const DataType &w) |
Get the maximum of four values. More... | |
template<class DataType > | |
const DataType & | Murl::Math::Clamp (const DataType &val, const DataType &min, const DataType &max) |
Clamp a value. More... | |
template<class DataType > | |
Bool | Murl::Math::IsNaN (DataType value) |
Check if a value is not a number (NaN). More... | |
template<class DataType > | |
Bool | Murl::Math::IsInfinite (DataType value) |
Check if a value is infinite (either positive infinity or negative infinity). More... | |
template<class DataType > | |
Bool | Murl::Math::IsFinite (DataType value) |
Check if a value is finite. More... | |
template<class DataType > | |
DataType | Murl::Math::Exp (DataType value) |
Get the the e number raised to the power of a value. More... | |
template<class DataType > | |
DataType | Murl::Math::Log (DataType value) |
Get the natural logarithm of a value. More... | |
template<class DataType > | |
DataType | Murl::Math::Log2 (DataType value) |
Get the base 2 logarithm of a value. More... | |
template<class DataType > | |
DataType | Murl::Math::Log10 (DataType value) |
Get the base 10 logarithm of a value. More... | |
template<class DataType > | |
DataType | Murl::Math::Sqrt (DataType value) |
Get the square root of a value. More... | |
template<class DataType > | |
DataType | Murl::Math::Pow (DataType base, DataType exponent) |
Get a base raised to the power of an exponent. More... | |
template<class DataType > | |
DataType | Murl::Math::Fmod (DataType numerator, DataType denominator) |
Get the remainder of a numerator divided by a denominator. More... | |
template<class DataType > | |
DataType | Murl::Math::ModF (DataType value, DataType &intPart) |
Get the integer part and the fractional part of a value. More... | |
template<class DataType > | |
DataType | Murl::Math::Remainder (DataType numerator, DataType denominator) |
Get the IEEE remainder of a numerator divided by a denominator. More... | |
template<class DataType > | |
DataType | Murl::Math::Sin (DataType radAngle) |
Get the sine of an angle value. More... | |
template<class DataType > | |
DataType | Murl::Math::Cos (DataType radAngle) |
Get the cosine of an angle value. More... | |
template<class DataType > | |
DataType | Murl::Math::Tan (DataType radAngle) |
Get the tangent of an angle value. More... | |
template<class DataType > | |
DataType | Murl::Math::ArcSin (DataType value) |
Get the arc sine of a value. More... | |
template<class DataType > | |
DataType | Murl::Math::ArcCos (DataType value) |
Get the arc cosine of a value. More... | |
template<class DataType > | |
DataType | Murl::Math::ArcTan (DataType value) |
Get the arc tangent of a value. More... | |
template<class DataType > | |
DataType | Murl::Math::ArcTan2 (DataType y, DataType x) |
Get the arc tangent of y divided by x. More... | |
template<class DataType > | |
DataType | Murl::Math::SinHyp (DataType value) |
Get the hyperbolic sine of an value. More... | |
template<class DataType > | |
DataType | Murl::Math::CosHyp (DataType value) |
Get the hyperbolic cosine of an value. More... | |
template<class DataType > | |
DataType | Murl::Math::TanHyp (DataType value) |
Get the hyperbolic tangent of an value. More... | |
template<class DataType > | |
DataType | Murl::Math::ArcSinHyp (DataType value) |
Get the hyperbolic arc sine of an value. More... | |
template<class DataType > | |
DataType | Murl::Math::ArcCosHyp (DataType value) |
Get the hyperbolic arc cosine of an value. More... | |
template<class DataType > | |
DataType | Murl::Math::ArcTanHyp (DataType value) |
Get the hyperbolic arc tangent of an value. More... | |
template<class DataType > | |
DataType | Murl::Math::Floor (DataType value) |
Round down to an integral value. More... | |
template<class DataType > | |
DataType | Murl::Math::Ceil (DataType value) |
Round up to an integral value. More... | |
template<class DataType > | |
DataType | Murl::Math::Round (DataType value) |
Round to an integral value, regardless of the rounding direction. More... | |
template<class DataType > | |
Bool | Murl::Math::IsEqual (const DataType &a, const DataType &b, const DataType &epsilon=Limits< DataType >::Epsilon()) |
Check if two values are equal within an epsilon range. More... | |
template<class DataType > | |
DataType | Murl::Math::DegToRad (DataType degrees) |
Convert degrees into radiants. More... | |
template<class DataType > | |
DataType | Murl::Math::RadToDeg (DataType radiants) |
Convert radiants into degrees. More... | |
template<class DataType > | |
DataType | Murl::Math::MapAngle (DataType angle) |
Map an angle into range [-PI . More... | |
template<class DataType > | |
DataType | Murl::Math::AddAngle (DataType angle1, DataType angle2) |
Calculate the sum of two angles. More... | |
template<class DataType > | |
DataType | Murl::Math::SubAngle (DataType angle1, DataType angle2) |
Calculate the difference between two angles. More... | |
UInt16 | Murl::Math::FloatToHalfFloat (Float value) |
Convert a given 32bit float value to 16bit ("half float"), represented by a UInt16 integer. More... | |
UInt16 | Murl::Math::IntToHalfFloat (UInt8 value) |
Convert a given 8bit unsigned integer value to a 16bit floating point value ("half float"), represented by a UInt16 integer. More... | |
Float | Murl::Math::HalfFloatToFloat (UInt16 value) |
Convert a given 16bit half float value stored in a UInt16 to a 32bit float value. More... | |
UInt8 | Murl::Math::HalfFloatToInt (UInt16 value) |
Convert a given 16bit half float value stored in a UInt16 to a 8bit unsigned integer value. More... | |
template<class DataTypeV , class DataTypeT > | |
DataTypeV | Murl::Math::Lerp (const DataTypeV &startValue, const DataTypeV &endValue, DataTypeT t) |
The linear interpolation template function. More... | |
template<class DataTypeT > | |
Double | Murl::Math::Lerp (Double startValue, Double endValue, DataTypeT t) |
The linear interpolation template function for Double. More... | |
template<class DataTypeV , class DataTypeT > | |
DataTypeT | Murl::Math::GetCubicBezierParameter (DataTypeV x0, DataTypeV x1, DataTypeV x2, DataTypeV x3, DataTypeV x) |
Get the cubic bezier parameter t for a given X value. More... | |
template<class DataTypeV , class DataTypeT > | |
DataTypeV | Murl::Math::CubicBezier (DataTypeV x0, DataTypeV x1, DataTypeV x2, DataTypeV x3, DataTypeT t) |
Evaluate a cubic bezier curve for a given parameter t. More... | |
template<class DataTypeV > | |
DataTypeV | Murl::Math::CubicBezierAt (DataTypeV x0, DataTypeV x1, DataTypeV x2, DataTypeV x3, DataTypeV y0, DataTypeV y1, DataTypeV y2, DataTypeV y3, DataTypeV x) |
Evaluate a cubic bezier curve at a given X value. More... | |
template<class DataType > | |
Easing< DataType >::Interpolate | Murl::Math::GetEasingFunction (IEnums::Interpolation interpolation) |
Get the Easing::Interpolate function for a specified interpolation. More... | |
template<class DataType > | |
DataType | Murl::Math::Interpolation (IEnums::Interpolation interpolation, DataType x) |
The interpolation template function calculates the IEnums::Interpolation curve (easing function). More... | |
Mathematic functions (Trigonometric, exponential, rounding, etc.).
Basic mathematic functions available for Float and Double data type.
DataType Murl::Math::Abs | ( | DataType | value | ) |
Get the absolute value.
value | The input value. |
DataType Murl::Math::Sgn | ( | DataType | value | ) |
Get the sign of a value.
value | The input value. |
const DataType& Murl::Math::Min | ( | const DataType & | x, |
const DataType & | y | ||
) |
Get the minimum of two values.
If both are equivalent, x is returned.
x | The 1st value. |
y | The 2nd value. |
const DataType& Murl::Math::Min | ( | const DataType & | x, |
const DataType & | y, | ||
const DataType & | z | ||
) |
Get the minimum of three values.
If all are equivalent, x is returned.
x | The 1st value. |
y | The 2nd value. |
z | The 3rd value. |
const DataType& Murl::Math::Min | ( | const DataType & | x, |
const DataType & | y, | ||
const DataType & | z, | ||
const DataType & | w | ||
) |
Get the minimum of four values.
If all are equivalent, x is returned.
x | The 1st value. |
y | The 2nd value. |
z | The 3rd value. |
w | The 4th value. |
const DataType& Murl::Math::Max | ( | const DataType & | x, |
const DataType & | y | ||
) |
Get the maximum of two values.
If both are equivalent, x is returned.
x | The 1st value. |
y | The 2nd value. |
const DataType& Murl::Math::Max | ( | const DataType & | x, |
const DataType & | y, | ||
const DataType & | z | ||
) |
Get the maximum of three values.
If all are equivalent, x is returned.
x | The 1st value. |
y | The 2nd value. |
z | The 3rd value. |
const DataType& Murl::Math::Max | ( | const DataType & | x, |
const DataType & | y, | ||
const DataType & | z, | ||
const DataType & | w | ||
) |
Get the maximum of four values.
If all are equivalent, x is returned.
x | The 1st value. |
y | The 2nd value. |
z | The 3rd value. |
w | The 4th value. |
const DataType& Murl::Math::Clamp | ( | const DataType & | val, |
const DataType & | min, | ||
const DataType & | max | ||
) |
Clamp a value.
val | The value to clamp. |
min | The minimum value. |
max | The maximum value. |
Bool Murl::Math::IsNaN | ( | DataType | value | ) |
Check if a value is not a number (NaN).
The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the result of 0/0.
value | The value to check. |
Bool Murl::Math::IsInfinite | ( | DataType | value | ) |
Check if a value is infinite (either positive infinity or negative infinity).
value | The value to check. |
Bool Murl::Math::IsFinite | ( | DataType | value | ) |
Check if a value is finite.
A finite value is any floating-point value that is neither infinite nor NaN.
value | The value to check. |
DataType Murl::Math::Exp | ( | DataType | value | ) |
Get the the e number raised to the power of a value.
value | The input value. |
DataType Murl::Math::Log | ( | DataType | value | ) |
Get the natural logarithm of a value.
value | The input value. |
DataType Murl::Math::Log2 | ( | DataType | value | ) |
Get the base 2 logarithm of a value.
value | The input value. |
DataType Murl::Math::Log10 | ( | DataType | value | ) |
Get the base 10 logarithm of a value.
value | The input value. |
DataType Murl::Math::Sqrt | ( | DataType | value | ) |
Get the square root of a value.
value | The input value. |
DataType Murl::Math::Pow | ( | DataType | base, |
DataType | exponent | ||
) |
Get a base raised to the power of an exponent.
base | The base input value. |
exponent | The exponent input value. |
DataType Murl::Math::Fmod | ( | DataType | numerator, |
DataType | denominator | ||
) |
Get the remainder of a numerator divided by a denominator.
numerator | The numerator input value. |
denominator | The denominator input value. |
DataType Murl::Math::ModF | ( | DataType | value, |
DataType & | intPart | ||
) |
Get the integer part and the fractional part of a value.
value | The input value. |
intPart | The integer part return value. |
DataType Murl::Math::Remainder | ( | DataType | numerator, |
DataType | denominator | ||
) |
Get the IEEE remainder of a numerator divided by a denominator.
numerator | The numerator input value. |
denominator | The denominator input value. |
DataType Murl::Math::Sin | ( | DataType | radAngle | ) |
Get the sine of an angle value.
radAngle | The angle value in radiants. |
DataType Murl::Math::Cos | ( | DataType | radAngle | ) |
Get the cosine of an angle value.
radAngle | The angle value in radiants. |
DataType Murl::Math::Tan | ( | DataType | radAngle | ) |
Get the tangent of an angle value.
radAngle | The angle value in radiants. |
DataType Murl::Math::ArcSin | ( | DataType | value | ) |
Get the arc sine of a value.
value | The input value. |
DataType Murl::Math::ArcCos | ( | DataType | value | ) |
Get the arc cosine of a value.
value | The input value. |
DataType Murl::Math::ArcTan | ( | DataType | value | ) |
Get the arc tangent of a value.
value | The input value. |
DataType Murl::Math::ArcTan2 | ( | DataType | y, |
DataType | x | ||
) |
Get the arc tangent of y divided by x.
The function uses the sign of both arguments to determine the quadrant.
y | The y input value. |
x | The x input value. |
DataType Murl::Math::SinHyp | ( | DataType | value | ) |
Get the hyperbolic sine of an value.
value | The input value. |
DataType Murl::Math::CosHyp | ( | DataType | value | ) |
Get the hyperbolic cosine of an value.
value | The input value. |
DataType Murl::Math::TanHyp | ( | DataType | value | ) |
Get the hyperbolic tangent of an value.
value | The input value. |
DataType Murl::Math::ArcSinHyp | ( | DataType | value | ) |
Get the hyperbolic arc sine of an value.
value | The input value. |
DataType Murl::Math::ArcCosHyp | ( | DataType | value | ) |
Get the hyperbolic arc cosine of an value.
value | The input value. |
DataType Murl::Math::ArcTanHyp | ( | DataType | value | ) |
Get the hyperbolic arc tangent of an value.
value | The input value. |
DataType Murl::Math::Floor | ( | DataType | value | ) |
Round down to an integral value.
value | The input value. |
DataType Murl::Math::Ceil | ( | DataType | value | ) |
Round up to an integral value.
value | The input value. |
DataType Murl::Math::Round | ( | DataType | value | ) |
Round to an integral value, regardless of the rounding direction.
Rounding half-way cases away from zero.
value | The input value. |
Bool Murl::Math::IsEqual | ( | const DataType & | a, |
const DataType & | b, | ||
const DataType & | epsilon = Limits<DataType>::Epsilon() |
||
) |
Check if two values are equal within an epsilon range.
a | The 1st value. |
b | The 2nd value. |
epsilon | The epsilon value. |
DataType Murl::Math::DegToRad | ( | DataType | degrees | ) |
Convert degrees into radiants.
degrees | The degrees to convert. |
DataType Murl::Math::RadToDeg | ( | DataType | radiants | ) |
Convert radiants into degrees.
radiants | The radiants to convert. |
DataType Murl::Math::MapAngle | ( | DataType | angle | ) |
Map an angle into range [-PI .
. PI).
angle | The angle value in radiants. |
DataType Murl::Math::AddAngle | ( | DataType | angle1, |
DataType | angle2 | ||
) |
Calculate the sum of two angles.
angle1 | The first angle value in radiants. |
angle2 | The second angle value in radiants. |
DataType Murl::Math::SubAngle | ( | DataType | angle1, |
DataType | angle2 | ||
) |
Calculate the difference between two angles.
angle1 | The first angle value in radiants. |
angle2 | The second angle value in radiants. |
Convert a given 32bit float value to 16bit ("half float"), represented by a UInt16 integer.
value | The 32bit float value to convert |
Convert a given 8bit unsigned integer value to a 16bit floating point value ("half float"), represented by a UInt16 integer.
The input value is divided by 255.
value | The 8bit unsigned integer value to convert |
Convert a given 16bit half float value stored in a UInt16 to a 32bit float value.
value | The 16bit float value to convert |
Convert a given 16bit half float value stored in a UInt16 to a 8bit unsigned integer value.
The output value is multiplied by 255.
value | The 16bit float value to convert |
DataTypeV Murl::Math::Lerp | ( | const DataTypeV & | startValue, |
const DataTypeV & | endValue, | ||
DataTypeT | t | ||
) |
The linear interpolation template function.
startValue | The start value to interpolate. |
endValue | The end value to interpolate. |
t | The parameter to interpolate in range [0 .. 1]. |
Double Murl::Math::Lerp | ( | Double | startValue, |
Double | endValue, | ||
DataTypeT | t | ||
) |
The linear interpolation template function for Double.
startValue | The start value to interpolate. |
endValue | The end value to interpolate. |
t | The parameter to interpolate in range [0 .. 1]. |
DataTypeT Murl::Math::GetCubicBezierParameter | ( | DataTypeV | x0, |
DataTypeV | x1, | ||
DataTypeV | x2, | ||
DataTypeV | x3, | ||
DataTypeV | x | ||
) |
Get the cubic bezier parameter t for a given X value.
This function interpolates the bezier parameter t (in the range [0..1] for a given target X value and the X values of the four curve control points.
x0 | The X value of the starting point (first control point) |
x1 | The X value of the second control point |
x2 | The X value of the third control point |
x3 | The X value of the end point (fourth control point) |
x | The target X value |
DataTypeV Murl::Math::CubicBezier | ( | DataTypeV | x0, |
DataTypeV | x1, | ||
DataTypeV | x2, | ||
DataTypeV | x3, | ||
DataTypeT | t | ||
) |
Evaluate a cubic bezier curve for a given parameter t.
This function returns the interpolated value of a cubic bezier curve defined via four control points and a given parameter t in the range [0..1].
x0 | The starting point (first control point) |
x1 | The second control point |
x2 | The third control point |
x3 | The end point (fourth control point) |
t | The curve parameter in the range [0..1] |
DataTypeV Murl::Math::CubicBezierAt | ( | DataTypeV | x0, |
DataTypeV | x1, | ||
DataTypeV | x2, | ||
DataTypeV | x3, | ||
DataTypeV | y0, | ||
DataTypeV | y1, | ||
DataTypeV | y2, | ||
DataTypeV | y3, | ||
DataTypeV | x | ||
) |
Evaluate a cubic bezier curve at a given X value.
This function returns the interpolated Y value of a cubic bezier curve defined via four (X,Y) control point pairs and a given target X value. If the target X value is outside the range [x0..x3], it is clamped to that range.
x0 | The X value of the starting point (first control point) |
x1 | The X value of the second control point |
x2 | The X value of the third control point |
x3 | The X value of the end point (fourth control point) |
y0 | The Y value of the starting point (first control point) |
y1 | The Y value of the second control point |
y2 | The Y value of the third control point |
y3 | The Y value of the end point (fourth control point) |
x | The target X value |
Easing<DataType>::Interpolate Murl::Math::GetEasingFunction | ( | IEnums::Interpolation | interpolation | ) |
Get the Easing::Interpolate function for a specified interpolation.
interpolation | The interpolation. |
DataType Murl::Math::Interpolation | ( | IEnums::Interpolation | interpolation, |
DataType | x | ||
) |
The interpolation template function calculates the IEnums::Interpolation curve (easing function).
interpolation | The interpolation. |
x | The value to interpolate in range [0 .. 1]. |