NVIDIA Iray: Math API Home  Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Math Functions

The math API provides functions and function templates that act on simple types or generic container and vector concepts. More...

Modules

  Basic Math Functors in the Math API
  Basic math functors in the Math API.
 
  Generic Functions in the Math API
  Generic functions in the Math API targeted to static vector-like sequences.
 
  Fast Approximations for float Math Functions
  Fast approximations for math functions on limited precision floats.
 

Namespaces

  mi::math::functor
  Namespace for basic math functors in the Math API.
 
  mi::math::general
  Namespace for generic functions in the Math API.
 

Functions

Float32  mi::math::exp (Float32 s)
  Returns the constant e to the power of s (exponential function). More...
 
Float64  mi::math::exp (Float64 s)
  Returns the constant e to the power of s (exponential function). More...
 
Float32  mi::math::log (Float32 s)
  Returns the natural logarithm of s. More...
 
Float64  mi::math::log (Float64 s)
  Returns the natural logarithm of s. More...
 
Float32  mi::math::acos (Float32 s)
  Returns the arc cosine of s in radians. More...
 
Float64  mi::math::acos (Float64 s)
  Returns the arc cosine of s in radians. More...
 
bool  mi::math::all (Uint8 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Uint16 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Uint32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Uint64 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Sint8 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Sint16 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Sint32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Sint64 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Float32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Float64 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Uint8 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Uint16 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Uint32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Uint64 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Sint8 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Sint16 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Sint32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Sint64 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Float32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Float64 v)
  Returns true if v is not equal to zero. More...
 
Float32  mi::math::asin (Float32 s)
  Returns the arc sine of s in radians. More...
 
Float64  mi::math::asin (Float64 s)
  Returns the arc sine of s in radians. More...
 
Float32  mi::math::atan (Float32 s)
  Returns the arc tangent of s. More...
 
Float64  mi::math::atan (Float64 s)
  Returns the arc tangent of s. More...
 
Float32  mi::math::atan2 (Float32 s, Float32 t)
  Returns the arc tangent of s / t. More...
 
Float64  mi::math::atan2 (Float64 s, Float64 t)
  Returns the arc tangent of s / t. More...
 
Float32  mi::math::ceil (Float32 s)
  Returns the smallest integral value that is not less than s. More...
 
Float64  mi::math::ceil (Float64 s)
  Returns the smallest integral value that is not less than s. More...
 
Uint8  mi::math::clamp (Uint8 s, Uint8 low, Uint8 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Uint16  mi::math::clamp (Uint16 s, Uint16 low, Uint16 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Uint32  mi::math::clamp (Uint32 s, Uint32 low, Uint32 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Uint64  mi::math::clamp (Uint64 s, Uint64 low, Uint64 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Sint8  mi::math::clamp (Sint8 s, Sint8 low, Sint8 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Sint16  mi::math::clamp (Sint16 s, Sint16 low, Sint16 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Sint32  mi::math::clamp (Sint32 s, Sint32 low, Sint32 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Sint64  mi::math::clamp (Sint64 s, Sint64 low, Sint64 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Float32  mi::math::clamp (Float32 s, Float32 low, Float32 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Float64  mi::math::clamp (Float64 s, Float64 low, Float64 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Float32  mi::math::cos (Float32 a)
  Returns the cosine of a. The angle a is specified in radians. More...
 
Float64  mi::math::cos (Float64 a)
  Returns the cosine of a. The angle a is specified in radians. More...
 
Float32  mi::math::degrees (Float32 r)
  Converts radians r to degrees. More...
 
Float64  mi::math::degrees (Float64 r)
  Converts radians r to degrees. More...
 
Float32  mi::math::exp2 (Float32 s)
  Returns the constant 2 to the power of s (exponential function). More...
 
Float64  mi::math::exp2 (Float64 s)
  Returns the constant 2 to the power of s (exponential function). More...
 
Float32  mi::math::floor (Float32 s)
  Returns the largest integral value that is not greater than s. More...
 
Float64  mi::math::floor (Float64 s)
  Returns the largest integral value that is not greater than s. More...
 
Float32  mi::math::fmod (Float32 a, Float32 b)
  Returns a modulo b, in other words, the remainder of a/b. More...
 
Float64  mi::math::fmod (Float64 a, Float64 b)
  Returns a modulo b, in other words, the remainder of a/b. More...
 
Float32  mi::math::frac (Float32 s)
  Returns the positive fractional part of s. More...
 
Float64  mi::math::frac (Float64 s)
  Returns the positive fractional part of s. More...
 
bool  mi::math::is_approx_equal (Float32 left, Float32 right, Float32 e)
  Compares the two given values for equality within the given epsilon. More...
 
bool  mi::math::is_approx_equal (Float64 left, Float64 right, Float64 e)
  Compares the two given values for equality within the given epsilon. More...
 
Float32  mi::math::log2 (Float32 s)
  Returns the base 2 logarithm of s. More...
 
Float64  mi::math::log2 (Float64 s)
  Returns the base 2 logarithm of s. More...
 
Float32  mi::math::log10 (Float32 s)
  Returns the base 10 logarithm of s. More...
 
Float64  mi::math::log10 (Float64 s)
  Returns the base 10 logarithm of s. More...
 
Float32  mi::math::lerp (Float32 s1, Float32 s2, Float32 t)
  Returns the linear interpolation between s1 and s2, i.e., it returns (1-t) * s1 + t * s2. More...
 
Float64  mi::math::lerp (Float64 s1, Float64 s2, Float64 t)
  Returns the linear interpolation between s1 and s2, i.e., it returns (1-t) * s1 + t * s2. More...
 
Float32  mi::math::modf (Float32 s, Float32 &i)
  Returns the fractional part of s and stores the integral part of s in i. More...
 
Float64  mi::math::modf (Float64 s, Float64 &i)
  Returns the fractional part of s and stores the integral part of s in i. More...
 
Uint32  mi::math::pow (Uint32 a, Uint32 b)
  Returns a to the power of b. More...
 
Uint64  mi::math::pow (Uint64 a, Uint64 b)
  Returns a to the power of b. More...
 
Sint32  mi::math::pow (Sint32 a, Sint32 b)
  Returns a to the power of b. More...
 
Sint64  mi::math::pow (Sint64 a, Sint64 b)
  Returns a to the power of b. More...
 
Float32  mi::math::pow (Float32 a, Float32 b)
  Returns a to the power of b. More...
 
Float64  mi::math::pow (Float64 a, Float64 b)
  Returns a to the power of b. More...
 
Float32  mi::math::radians (Float32 d)
  Converts degrees d to radians. More...
 
Float64  mi::math::radians (Float64 d)
  Converts degrees d to radians. More...
 
Float32  mi::math::round (Float32 s)
  Returns s rounded to the nearest integer value. More...
 
Float64  mi::math::round (Float64 s)
  Returns s rounded to the nearest integer value. More...
 
Float32  mi::math::rsqrt (Float32 s)
  Returns the reciprocal of the square root of s. More...
 
Float64  mi::math::rsqrt (Float64 s)
  Returns the reciprocal of the square root of s. More...
 
Float32  mi::math::saturate (Float32 s)
  Returns the value s clamped to the range [0,1]. More...
 
Float64  mi::math::saturate (Float64 s)
  Returns the value s clamped to the range [0,1]. More...
 
Sint8  mi::math::sign (Sint8 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
Sint16  mi::math::sign (Sint16 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
Sint32  mi::math::sign (Sint32 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
Sint64  mi::math::sign (Sint64 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
Float32  mi::math::sign (Float32 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
Float64  mi::math::sign (Float64 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
bool  mi::math::sign_bit (Sint8 s)
  Returns true if s<0 and false if s>= 0. More...
 
bool  mi::math::sign_bit (Sint16 s)
  Returns true if s<0 and false if s>= 0. More...
 
bool  mi::math::sign_bit (Sint32 s)
  Returns true if s<0 and false if s>= 0. More...
 
bool  mi::math::sign_bit (Sint64 s)
  Returns true if s<0 and false if s>= 0. More...
 
bool  mi::math::sign_bit (Float32 s)
  Extracts the sign bit of a single-precision floating point number. More...
 
bool  mi::math::sign_bit (Float64 s)
  Extracts the sign bit of a double-precision floating point number. More...
 
bool  mi::math::isnan (const Float32 x)
  Checks a single-precision floating point number for "not a number". More...
 
bool  mi::math::isnan (const Float64 x)
  Checks a double-precision floating point number for "not a number". More...
 
bool  mi::math::isinfinite (const Float32 x)
  Checks a single-precision floating point number for "infinity". More...
 
bool  mi::math::isinfinite (const Float64 x)
  Checks a double-precision floating point number for "infinity". More...
 
bool  mi::math::isfinite (const Float32 x)
  Checks a single-precision floating point number for neither "not a number" nor "infinity". More...
 
bool  mi::math::isfinite (const Float64 x)
  Checks a double-precision floating point number for neither "not a number" nor "infinity". More...
 
Float32  mi::math::sin (Float32 a)
  Returns the sine of a. The angle a is specified in radians. More...
 
Float64  mi::math::sin (Float64 a)
  Returns the sine of a. The angle a is specified in radians. More...
 
void  mi::math::sincos (Float32 a, Float32 &s, Float32 &c)
  Computes the sine s and cosine c of angle a simultaneously. More...
 
void  mi::math::sincos (Float64 a, Float64 &s, Float64 &c)
  Computes the sine s and cosine c of angle a simultaneously. More...
 
Float32  mi::math::smoothstep (Float32 a, Float32 b, Float32 x)
  Returns 0 if x is less than a and 1 if x is greater than b. More...
 
Float64  mi::math::smoothstep (Float64 a, Float64 b, Float64 x)
  Returns 0 if x is less than a and 1 if x is greater than b. More...
 
Float32  mi::math::sqrt (Float32 s)
  Returns the square root of s. More...
 
Float64  mi::math::sqrt (Float64 s)
  Returns the square root of s. More...
 
Float32  mi::math::step (Float32 a, Float32 x)
  Returns 0 if x is less than a and 1 otherwise. More...
 
Float64  mi::math::step (Float64 a, Float64 x)
  Returns 0 if x is less than a and 1 otherwise. More...
 
Float32  mi::math::tan (Float32 a)
  Returns the tangent of a. The angle a is specified in radians. More...
 
Float64  mi::math::tan (Float64 a)
  Returns the tangent of a. The angle a is specified in radians. More...
 
void  mi::math::to_rgbe (const Float32 color[3], Uint32 &rgbe)
  Encodes a color into RGBE representation. More...
 
void  mi::math::to_rgbe (const Float32 color[3], Uint8 rgbe[4])
  Encodes a color into RGBE representation. More...
 
void  mi::math::from_rgbe (const Uint8 rgbe[4], Float32 color[3])
  Decodes a color from RGBE representation. More...
 
void  mi::math::from_rgbe (const Uint32 rgbe, Float32 color[3])
  Decodes a color from RGBE representation. More...
 
Sint32  mi::math::dot (Sint32 a, Sint32 b)
  Returns the inner product (a.k.a. dot or scalar product) of two integers. More...
 
Float32  mi::math::dot (Float32 a, Float32 b)
  Returns the inner product (a.k.a. dot or scalar product) of two scalars. More...
 
Float64  mi::math::dot (Float64 a, Float64 b)
  Returns the inner product (a.k.a. dot or scalar product) of two scalars. More...
 
template<class V >
V::value_type  mi::math::dot (const V &lhs, const V &rhs)
  Returns the inner product (a.k.a. dot or scalar product) of two vectors. More...
 
template<class V >
V::value_type  mi::math::square_length (const V &v)
  Returns the squared Euclidean norm of the vector v. More...
 
Float32  mi::math::length (Float32 a)
  Returns the Euclidean norm of the scalar a (its absolute value). More...
 
Float64  mi::math::length (Float64 a)
  Returns the Euclidean norm of the scalar a (its absolute value). More...
 
template<class V >
V::value_type  mi::math::length (const V &v)
  Returns the Euclidean norm of the vector v. More...
 
template<class V >
V::value_type  mi::math::square_euclidean_distance (const V &lhs, const V &rhs)
  Returns the squared Euclidean distance from the vector lhs to the vector rhs. More...
 
template<class V >
V::value_type  mi::math::euclidean_distance (const V &lhs, const V &rhs)
  Returns the Euclidean distance from the vector lhs to the vector rhs. More...
 
template<class V >
void  mi::math::set_bounds (V &v, const V &low, const V &high)
  Bounds the value of vector v elementwise to the given low and high vector values. More...
 
template<class V >
bool  mi::math::is_equal (const V &lhs, const V &rhs)
  Returns true if vector lhs is elementwise equal to vector rhs, and false otherwise. More...
 
template<class V >
bool  mi::math::is_not_equal (const V &lhs, const V &rhs)
  Returns true if vector lhs is elementwise not equal to vector rhs, and false otherwise. More...
 
template<class V >
bool  mi::math::lexicographically_less (const V &lhs, const V &rhs)
  Returns true if vector lhs is lexicographically less than vector rhs, and false otherwise. More...
 
template<class V >
bool  mi::math::lexicographically_less_or_equal (const V &lhs, const V &rhs)
  Returns true if vector lhs is lexicographically less than or equal to vector rhs, and false otherwise. More...
 
template<class V >
bool  mi::math::lexicographically_greater (const V &lhs, const V &rhs)
  Returns true if vector lhs is lexicographically greater than vector rhs, and false otherwise. More...
 
template<class V >
bool  mi::math::lexicographically_greater_or_equal (const V &lhs, const V &rhs)
  Returns true if vector lhs is lexicographically greater than or equal to vector rhs, and false otherwise. More...
 
template<class V >
Comparison_result  mi::math::lexicographically_compare (const V &lhs, const V &rhs)
  Compares two vectors lexicographically. More...
 

Detailed Description

The math API provides functions and function templates that act on simple types or generic container and vector concepts.

Examples are trigonometric functions or lexicographically_compare().

Functions exist typically as a family of overloaded functions for all applicable argument types, such as trigonometric functions, or as a single function template for a vector-like concept, such as lexicographically_compare().

Generic function templates on vector-like value require the vector-like type to have a compile-time constant SIZE as local value, defining the number of elements in the value, and operator[] style access to these elements.

Overloaded functions may have additional overloads for various non-simple types, such as mi::math::Vector or mi::math::Color.

Functions in this group are intended for unqualified naming, such that argument-dependent name lookup (ADL, a.k.a. extended Koenig lookup) can be used with them.

The basic function templates for min() and max(), as well as the overloaded abs() functions are taken from the mi::base namespace.

Include File:
#include <mi/math/function.h>

Function Documentation

Float32 mi::math::acos ( Float32  s)
inline

Returns the arc cosine of s in radians.

Float64 mi::math::acos ( Float64  s)
inline

Returns the arc cosine of s in radians.

bool mi::math::all ( Uint8  v)
inline

Returns true if v is not equal to zero.

bool mi::math::all ( Uint16  v)
inline

Returns true if v is not equal to zero.

bool mi::math::all ( Uint32  v)
inline

Returns true if v is not equal to zero.

bool mi::math::all ( Uint64  v)
inline

Returns true if v is not equal to zero.

bool mi::math::all ( Sint8  v)
inline

Returns true if v is not equal to zero.

bool mi::math::all ( Sint16  v)
inline

Returns true if v is not equal to zero.

bool mi::math::all ( Sint32  v)
inline

Returns true if v is not equal to zero.

bool mi::math::all ( Sint64  v)
inline

Returns true if v is not equal to zero.

bool mi::math::all ( Float32  v)
inline

Returns true if v is not equal to zero.

bool mi::math::all ( Float64  v)
inline

Returns true if v is not equal to zero.

bool mi::math::any ( Uint8  v)
inline

Returns true if v is not equal to zero.

bool mi::math::any ( Uint16  v)
inline

Returns true if v is not equal to zero.

bool mi::math::any ( Uint32  v)
inline

Returns true if v is not equal to zero.

bool mi::math::any ( Uint64  v)
inline

Returns true if v is not equal to zero.

bool mi::math::any ( Sint8  v)
inline

Returns true if v is not equal to zero.

bool mi::math::any ( Sint16  v)
inline

Returns true if v is not equal to zero.

bool mi::math::any ( Sint32  v)
inline

Returns true if v is not equal to zero.

bool mi::math::any ( Sint64  v)
inline

Returns true if v is not equal to zero.

bool mi::math::any ( Float32  v)
inline

Returns true if v is not equal to zero.

bool mi::math::any ( Float64  v)
inline

Returns true if v is not equal to zero.

Float32 mi::math::asin ( Float32  s)
inline

Returns the arc sine of s in radians.

Float64 mi::math::asin ( Float64  s)
inline

Returns the arc sine of s in radians.

Float32 mi::math::atan ( Float32  s)
inline

Returns the arc tangent of s.

Float64 mi::math::atan ( Float64  s)
inline

Returns the arc tangent of s.

Float32 mi::math::atan2 ( Float32  s,
Float32  t 
)
inline

Returns the arc tangent of s / t.

The signs of s and t are used to determine the quadrant of the results.

Float64 mi::math::atan2 ( Float64  s,
Float64  t 
)
inline

Returns the arc tangent of s / t.

The signs of s and t are used to determine the quadrant of the results.

Float32 mi::math::ceil ( Float32  s)
inline

Returns the smallest integral value that is not less than s.

Float64 mi::math::ceil ( Float64  s)
inline

Returns the smallest integral value that is not less than s.

Uint8 mi::math::clamp ( Uint8  s,
Uint8  low,
Uint8  high 
)
inline

Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high.

Uint16 mi::math::clamp ( Uint16  s,
Uint16  low,
Uint16  high 
)
inline

Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high.

Uint32 mi::math::clamp ( Uint32  s,
Uint32  low,
Uint32  high 
)
inline

Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high.

Uint64 mi::math::clamp ( Uint64  s,
Uint64  low,
Uint64  high 
)
inline

Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high.

Sint8 mi::math::clamp ( Sint8  s,
Sint8  low,
Sint8  high 
)
inline

Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high.

Sint16 mi::math::clamp ( Sint16  s,
Sint16  low,
Sint16  high 
)
inline

Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high.

Sint32 mi::math::clamp ( Sint32  s,
Sint32  low,
Sint32  high 
)
inline

Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high.

Sint64 mi::math::clamp ( Sint64  s,
Sint64  low,
Sint64  high 
)
inline

Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high.

Float32 mi::math::clamp ( Float32  s,
Float32  low,
Float32  high 
)
inline

Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high.

Float64 mi::math::clamp ( Float64  s,
Float64  low,
Float64  high 
)
inline

Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high.

Float32 mi::math::cos ( Float32  a)
inline

Returns the cosine of a. The angle a is specified in radians.

Float64 mi::math::cos ( Float64  a)
inline

Returns the cosine of a. The angle a is specified in radians.

Float32 mi::math::degrees ( Float32  r)
inline

Converts radians r to degrees.

Float64 mi::math::degrees ( Float64  r)
inline

Converts radians r to degrees.

Sint32 mi::math::dot ( Sint32  a,
Sint32  b 
)
inline

Returns the inner product (a.k.a. dot or scalar product) of two integers.

Float32 mi::math::dot ( Float32  a,
Float32  b 
)
inline

Returns the inner product (a.k.a. dot or scalar product) of two scalars.

Float64 mi::math::dot ( Float64  a,
Float64  b 
)
inline

Returns the inner product (a.k.a. dot or scalar product) of two scalars.

template<class V >
V::value_type mi::math::dot ( const V &  lhs,
const V &  rhs 
)
inline

Returns the inner product (a.k.a. dot or scalar product) of two vectors.

template<class V >
V::value_type mi::math::euclidean_distance ( const V &  lhs,
const V &  rhs 
)
inline

Returns the Euclidean distance from the vector lhs to the vector rhs.

Uses an unqualified call to sqrt(...) on the vector element type.

Float32 mi::math::exp ( Float32  s)
inline

Returns the constant e to the power of s (exponential function).

Float64 mi::math::exp ( Float64  s)
inline

Returns the constant e to the power of s (exponential function).

Float32 mi::math::exp2 ( Float32  s)
inline

Returns the constant 2 to the power of s (exponential function).

Float64 mi::math::exp2 ( Float64  s)
inline

Returns the constant 2 to the power of s (exponential function).

Float32 mi::math::floor ( Float32  s)
inline

Returns the largest integral value that is not greater than s.

Float64 mi::math::floor ( Float64  s)
inline

Returns the largest integral value that is not greater than s.

Float32 mi::math::fmod ( Float32  a,
Float32  b 
)
inline

Returns a modulo b, in other words, the remainder of a/b.

The result has the same sign as a.

Float64 mi::math::fmod ( Float64  a,
Float64  b 
)
inline

Returns a modulo b, in other words, the remainder of a/b.

The result has the same sign as a.

Float32 mi::math::frac ( Float32  s)
inline

Returns the positive fractional part of s.

Float64 mi::math::frac ( Float64  s)
inline

Returns the positive fractional part of s.

void mi::math::from_rgbe ( const Uint8  rgbe[4],
Float32  color[3] 
)
inline

Decodes a color from RGBE representation.

void mi::math::from_rgbe ( const Uint32  rgbe,
Float32  color[3] 
)
inline

Decodes a color from RGBE representation.

bool mi::math::is_approx_equal ( Float32  left,
Float32  right,
Float32  e 
)
inline

Compares the two given values for equality within the given epsilon.

bool mi::math::is_approx_equal ( Float64  left,
Float64  right,
Float64  e 
)
inline

Compares the two given values for equality within the given epsilon.

template<class V >
bool mi::math::is_equal ( const V &  lhs,
const V &  rhs 
)
inline

Returns true if vector lhs is elementwise equal to vector rhs, and false otherwise.

template<class V >
bool mi::math::is_not_equal ( const V &  lhs,
const V &  rhs 
)
inline

Returns true if vector lhs is elementwise not equal to vector rhs, and false otherwise.

bool mi::math::isfinite ( const Float32  x)
inline

Checks a single-precision floating point number for neither "not a number" nor "infinity".

The methods relies on the IEEE 754 floating-point standard. Note that the result of this function might differ from negating the result value of isinfinite() because of the "not a number" check.

bool mi::math::isfinite ( const Float64  x)
inline

Checks a double-precision floating point number for neither "not a number" nor "infinity".

The methods relies on the IEEE 754 floating-point standard. Note that the result of this function might differ from negating the result value of isinfinite() because of the "not a number" check.

bool mi::math::isinfinite ( const Float32  x)
inline

Checks a single-precision floating point number for "infinity".

The methods relies on the IEEE 754 floating-point standard.

bool mi::math::isinfinite ( const Float64  x)
inline

Checks a double-precision floating point number for "infinity".

The methods relies on the IEEE 754 floating-point standard.

bool mi::math::isnan ( const Float32  x)
inline

Checks a single-precision floating point number for "not a number".

The methods relies on the IEEE 754 floating-point standard.

bool mi::math::isnan ( const Float64  x)
inline

Checks a double-precision floating point number for "not a number".

The methods relies on the IEEE 754 floating-point standard.

Float32 mi::math::length ( Float32  a)
inline

Returns the Euclidean norm of the scalar a (its absolute value).

Float64 mi::math::length ( Float64  a)
inline

Returns the Euclidean norm of the scalar a (its absolute value).

template<class V >
V::value_type mi::math::length ( const V &  v)
inline

Returns the Euclidean norm of the vector v.

Uses an unqualified call to sqrt(...) on the vector element type.

Float32 mi::math::lerp ( Float32  s1,
Float32  s2,
Float32  t 
)
inline

Returns the linear interpolation between s1 and s2, i.e., it returns (1-t) * s1 + t * s2.

Parameters
s1 one scalar
s2 second scalar
t interpolation parameter in [0,1]
Float64 mi::math::lerp ( Float64  s1,
Float64  s2,
Float64  t 
)
inline

Returns the linear interpolation between s1 and s2, i.e., it returns (1-t) * s1 + t * s2.

Parameters
s1 one scalar
s2 second scalar
t interpolation parameter in [0,1]
template<class V >
Comparison_result mi::math::lexicographically_compare ( const V &  lhs,
const V &  rhs 
)
inline

Compares two vectors lexicographically.

Returns LESS if lhs is less than rhs, and correspondingly EQUAL or GREATER for the other cases.

Note
The result of this function is undefined if lhs or rhs contains NaNs.
See Also
mi::Comparison_result, Definition: Lexicographic order and comparison
template<class V >
bool mi::math::lexicographically_greater ( const V &  lhs,
const V &  rhs 
)
inline

Returns true if vector lhs is lexicographically greater than vector rhs, and false otherwise.

See Also
Definition: Lexicographic order and comparison
template<class V >
bool mi::math::lexicographically_greater_or_equal ( const V &  lhs,
const V &  rhs 
)
inline

Returns true if vector lhs is lexicographically greater than or equal to vector rhs, and false otherwise.

See Also
Definition: Lexicographic order and comparison
template<class V >
bool mi::math::lexicographically_less ( const V &  lhs,
const V &  rhs 
)
inline

Returns true if vector lhs is lexicographically less than vector rhs, and false otherwise.

See Also
Definition: Lexicographic order and comparison
template<class V >
bool mi::math::lexicographically_less_or_equal ( const V &  lhs,
const V &  rhs 
)
inline

Returns true if vector lhs is lexicographically less than or equal to vector rhs, and false otherwise.

See Also
Definition: Lexicographic order and comparison
Float32 mi::math::log ( Float32  s)
inline

Returns the natural logarithm of s.

Float64 mi::math::log ( Float64  s)
inline

Returns the natural logarithm of s.

Float32 mi::math::log10 ( Float32  s)
inline

Returns the base 10 logarithm of s.

Float64 mi::math::log10 ( Float64  s)
inline

Returns the base 10 logarithm of s.

Float32 mi::math::log2 ( Float32  s)
inline

Returns the base 2 logarithm of s.

Float64 mi::math::log2 ( Float64  s)
inline

Returns the base 2 logarithm of s.

Float32 mi::math::modf ( Float32  s,
Float32 &  i 
)
inline

Returns the fractional part of s and stores the integral part of s in i.

Both parts have the same sign as s.

Float64 mi::math::modf ( Float64  s,
Float64 &  i 
)
inline

Returns the fractional part of s and stores the integral part of s in i.

Both parts have the same sign as s.

Uint32 mi::math::pow ( Uint32  a,
Uint32  b 
)
inline

Returns a to the power of b.

Uint64 mi::math::pow ( Uint64  a,
Uint64  b 
)
inline

Returns a to the power of b.

Sint32 mi::math::pow ( Sint32  a,
Sint32  b 
)
inline

Returns a to the power of b.

Sint64 mi::math::pow ( Sint64  a,
Sint64  b 
)
inline

Returns a to the power of b.

Float32 mi::math::pow ( Float32  a,
Float32  b 
)
inline

Returns a to the power of b.

Float64 mi::math::pow ( Float64  a,
Float64  b 
)
inline

Returns a to the power of b.

Float32 mi::math::radians ( Float32  d)
inline

Converts degrees d to radians.

Float64 mi::math::radians ( Float64  d)
inline

Converts degrees d to radians.

Float32 mi::math::round ( Float32  s)
inline

Returns s rounded to the nearest integer value.

Float64 mi::math::round ( Float64  s)
inline

Returns s rounded to the nearest integer value.

Float32 mi::math::rsqrt ( Float32  s)
inline

Returns the reciprocal of the square root of s.

Float64 mi::math::rsqrt ( Float64  s)
inline

Returns the reciprocal of the square root of s.

Float32 mi::math::saturate ( Float32  s)
inline

Returns the value s clamped to the range [0,1].

Float64 mi::math::saturate ( Float64  s)
inline

Returns the value s clamped to the range [0,1].

template<class V >
void mi::math::set_bounds ( V &  v,
const V &  low,
const V &  high 
)
inline

Bounds the value of vector v elementwise to the given low and high vector values.

Sint8 mi::math::sign ( Sint8  s)
inline

Returns -1 if s<0, 0 if s==0, and +1 if s>0.

Sint16 mi::math::sign ( Sint16  s)
inline

Returns -1 if s<0, 0 if s==0, and +1 if s>0.

Sint32 mi::math::sign ( Sint32  s)
inline

Returns -1 if s<0, 0 if s==0, and +1 if s>0.

Sint64 mi::math::sign ( Sint64  s)
inline

Returns -1 if s<0, 0 if s==0, and +1 if s>0.

Float32 mi::math::sign ( Float32  s)
inline

Returns -1 if s<0, 0 if s==0, and +1 if s>0.

Float64 mi::math::sign ( Float64  s)
inline

Returns -1 if s<0, 0 if s==0, and +1 if s>0.

bool mi::math::sign_bit ( Sint8  s)
inline

Returns true if s<0 and false if s>= 0.

bool mi::math::sign_bit ( Sint16  s)
inline

Returns true if s<0 and false if s>= 0.

bool mi::math::sign_bit ( Sint32  s)
inline

Returns true if s<0 and false if s>= 0.

bool mi::math::sign_bit ( Sint64  s)
inline

Returns true if s<0 and false if s>= 0.

bool mi::math::sign_bit ( Float32  s)
inline

Extracts the sign bit of a single-precision floating point number.

The methods relies on the IEEE 754 floating-point standard. Note that the sign bit is set for the special floating-point value -0.0f, so this function returns true for this value.

bool mi::math::sign_bit ( Float64  s)
inline

Extracts the sign bit of a double-precision floating point number.

The methods relies on the IEEE 754 floating-point standard. Note that the sign bit is set for the special floating-point value -0.0f, so this function returns true for this value.

Float32 mi::math::sin ( Float32  a)
inline

Returns the sine of a. The angle a is specified in radians.

Float64 mi::math::sin ( Float64  a)
inline

Returns the sine of a. The angle a is specified in radians.

void mi::math::sincos ( Float32  a,
Float32 &  s,
Float32 &  c 
)
inline

Computes the sine s and cosine c of angle a simultaneously.

The angle a is specified in radians.

void mi::math::sincos ( Float64  a,
Float64 &  s,
Float64 &  c 
)
inline

Computes the sine s and cosine c of angle a simultaneously.

The angle a is specified in radians.

Float32 mi::math::smoothstep ( Float32  a,
Float32  b,
Float32  x 
)
inline

Returns 0 if x is less than a and 1 if x is greater than b.

A smooth curve is applied in-between so that the return value varies continuously from 0 to 1 as x varies from a to b.

Float64 mi::math::smoothstep ( Float64  a,
Float64  b,
Float64  x 
)
inline

Returns 0 if x is less than a and 1 if x is greater than b.

A smooth curve is applied in-between so that the return value varies continuously from 0 to 1 as x varies from a to b.

Float32 mi::math::sqrt ( Float32  s)
inline

Returns the square root of s.

Float64 mi::math::sqrt ( Float64  s)
inline

Returns the square root of s.

template<class V >
V::value_type mi::math::square_euclidean_distance ( const V &  lhs,
const V &  rhs 
)
inline

Returns the squared Euclidean distance from the vector lhs to the vector rhs.

template<class V >
V::value_type mi::math::square_length ( const V &  v)
inline

Returns the squared Euclidean norm of the vector v.

Float32 mi::math::step ( Float32  a,
Float32  x 
)
inline

Returns 0 if x is less than a and 1 otherwise.

Float64 mi::math::step ( Float64  a,
Float64  x 
)
inline

Returns 0 if x is less than a and 1 otherwise.

Float32 mi::math::tan ( Float32  a)
inline

Returns the tangent of a. The angle a is specified in radians.

Float64 mi::math::tan ( Float64  a)
inline

Returns the tangent of a. The angle a is specified in radians.

void mi::math::to_rgbe ( const Float32  color[3],
Uint32 &  rgbe 
)
inline

Encodes a color into RGBE representation.

void mi::math::to_rgbe ( const Float32  color[3],
Uint8  rgbe[4] 
)
inline

Encodes a color into RGBE representation.