Material Definition Language API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vector.h File Reference

Math vector class template of fixed dimension with arithmetic operators and generic functions. More...

Go to the source code of this file.

Classes

struct  mi::math::Color_struct
 Generic storage class template for an RGBA color representation storing four floating points elements. More...
 
struct  mi::math::Vector_struct< T, DIM >
 Generic storage class template for math vector representations storing DIM elements of type T. More...
 
struct  mi::math::Vector_struct< T, 1 >
 Specialization for dimension 1 to create x member. More...
 
struct  mi::math::Vector_struct< T, 2 >
 Specialization for dimension 2 to create x and y member. More...
 
struct  mi::math::Vector_struct< T, 3 >
 Specialization for dimension 3 to create x, y, and z members. More...
 
struct  mi::math::Vector_struct< T, 4 >
 Specialization for dimension 4 to create x, y, z, and w members. More...
 
class  mi::math::Vector< T, DIM >
 Fixed-size math vector class template with generic operations. More...
 
class  mi::math::Vector< T, DIM >
 Fixed-size math vector class template with generic operations. More...
 

Namespaces

 mi
 Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
 
 mi::math
 Namespace for the Math API.
 

Constant Groups

 mi
 Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
 
 mi::math
 Namespace for the Math API.
 

Enumerations

enum  mi::math::From_iterator_tag { mi::math::FROM_ITERATOR }
 Enum used for initializing a vector from an iterator. More...
 

Functions

template<typename T , Size DIM>
T * mi::math::vector_base_ptr (Vector_struct< T, DIM > &vec)
 Returns the base pointer to the vector data. More...
 
template<typename T , Size DIM>
const T * mi::math::vector_base_ptr (const Vector_struct< T, DIM > &vec)
 Returns the base pointer to the vector data. More...
 
template<typename T >
T * mi::math::vector_base_ptr (Vector_struct< T, 1 > &vec)
 Returns the base pointer to the vector data, specialization for DIM==1. More...
 
template<typename T >
const T * mi::math::vector_base_ptr (const Vector_struct< T, 1 > &vec)
 Returns the base pointer to the vector data, specialization for DIM==1. More...
 
template<typename T >
T * mi::math::vector_base_ptr (Vector_struct< T, 2 > &vec)
 Returns the base pointer to the vector data, specialization for DIM==2. More...
 
template<typename T >
const T * mi::math::vector_base_ptr (const Vector_struct< T, 2 > &vec)
 Returns the base pointer to the vector data, specialization for DIM==2. More...
 
template<typename T >
T * mi::math::vector_base_ptr (Vector_struct< T, 3 > &vec)
 Returns the base pointer to the vector data, specialization for DIM==3. More...
 
template<typename T >
const T * mi::math::vector_base_ptr (const Vector_struct< T, 3 > &vec)
 Returns the base pointer to the vector data, specialization for DIM==3. More...
 
template<typename T >
T * mi::math::vector_base_ptr (Vector_struct< T, 4 > &vec)
 Returns the base pointer to the vector data, specialization for DIM==4. More...
 
template<typename T >
const T * mi::math::vector_base_ptr (const Vector_struct< T, 4 > &vec)
 Returns the base pointer to the vector data, specialization for DIM==4. More...
 
template<typename T , Size DIM>
Vector< T, DIM > & mi::math::operator+= (Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Adds rhs elementwise to lhs and returns the modified lhs. More...
 
template<typename T , Size DIM>
Vector< T, DIM > & mi::math::operator-= (Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Subtracts rhs elementwise from lhs and returns the modified lhs. More...
 
template<typename T , Size DIM>
Vector< T, DIM > & mi::math::operator*= (Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Multiplies rhs elementwise with lhs and returns the modified lhs. More...
 
template<typename T , Size DIM>
Vector< T, DIM > & mi::math::operator%= (Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Computes lhs modulo rhs elementwise and returns the modified lhs. Only defined for typenames T having the % operator. More...
 
template<typename T , typename U , Size DIM>
Vector< T, DIM > & mi::math::operator/= (Vector< T, DIM > &lhs, const Vector< U, DIM > &rhs)
 Divides lhs elementwise by rhs and returns the modified lhs. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::operator+ (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Adds lhs and rhs elementwise and returns the new result. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::operator- (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Subtracts rhs elementwise from lhs and returns the new result. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::operator* (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Multiplies rhs elementwise with lhs and returns the new result. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::operator% (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Computes lhs modulo rhs elementwise and returns the new result. Only defined for typenames T having the % operator. More...
 
template<typename T , typename U , Size DIM>
Vector< T, DIM > mi::math::operator/ (const Vector< T, DIM > &lhs, const Vector< U, DIM > &rhs)
 Divides rhs elementwise by lhs and returns the new result. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::operator- (const Vector< T, DIM > &v)
 Negates the vector v elementwise and returns the new result. More...
 
template<typename T , typename TT , Size DIM>
Vector< T, DIM > & mi::math::operator*= (Vector< T, DIM > &v, TT s)
 Multiplies the vector v elementwise with the scalar s and returns the modified vector v. More...
 
template<typename T , typename TT , Size DIM>
Vector< T, DIM > & mi::math::operator%= (Vector< T, DIM > &v, TT s)
 Computes v modulo s elementwise and returns the modified vector v. More...
 
template<typename T , typename TT , Size DIM>
Vector< T, DIM > & mi::math::operator/= (Vector< T, DIM > &v, TT s)
 Divides the vector v elementwise by the scalar s and returns the modified vector v. More...
 
template<typename T , typename TT , Size DIM>
Vector< T, DIM > mi::math::operator* (const Vector< T, DIM > &v, TT s)
 Multiplies the vector v elementwise with the scalar s and returns the new result. More...
 
template<typename T , typename TT , Size DIM>
Vector< T, DIM > mi::math::operator* (TT s, const Vector< T, DIM > &v)
 Multiplies the vector v elementwise with the scalar s and returns the new result. More...
 
template<typename T , typename TT , Size DIM>
Vector< T, DIM > mi::math::operator% (const Vector< T, DIM > &v, TT s)
 Computes v modulo s elementwise and returns the new result. More...
 
template<typename T , typename TT , Size DIM>
Vector< T, DIM > mi::math::operator/ (const Vector< T, DIM > &v, TT s)
 Divides the vector v elementwise by the scalar s and returns the new result. More...
 
template<typename T , Size DIM>
Vector< T, DIM > & mi::math::operator++ (Vector< T, DIM > &vec)
 Pre-increments all elements of vec and returns the result. Modifies vec. More...
 
template<typename T , Size DIM>
Vector< T, DIM > & mi::math::operator-- (Vector< T, DIM > &vec)
 Pre-decrements all elements of vec and returns the result. Modifies vec. More...
 
template<Size DIM>
Vector< bool, DIM > mi::math::operator&& (const Vector< bool, DIM > &lhs, const Vector< bool, DIM > &rhs)
 Returns the elementwise logical and of two boolean vectors. More...
 
template<Size DIM>
Vector< bool, DIM > mi::math::operator&& (bool lhs, const Vector< bool, DIM > &rhs)
 Returns the elementwise logical and of a bool and a boolean vector. More...
 
template<Size DIM>
Vector< bool, DIM > mi::math::operator&& (const Vector< bool, DIM > &lhs, bool rhs)
 Returns the elementwise logical and of a boolean vector and a bool. More...
 
template<Size DIM>
Vector< bool, DIM > mi::math::operator|| (const Vector< bool, DIM > &lhs, const Vector< bool, DIM > &rhs)
 Returns the elementwise logical or of two boolean vectors. More...
 
template<Size DIM>
Vector< bool, DIM > mi::math::operator|| (bool lhs, const Vector< bool, DIM > &rhs)
 Returns the elementwise logical or of a bool and a boolean vector. More...
 
template<Size DIM>
Vector< bool, DIM > mi::math::operator|| (const Vector< bool, DIM > &lhs, bool rhs)
 Returns the elementwise logical or of a boolean vector and a bool. More...
 
template<Size DIM>
Vector< bool, DIM > mi::math::operator^ (const Vector< bool, DIM > &lhs, const Vector< bool, DIM > &rhs)
 Returns the elementwise logical xor of two boolean vectors. More...
 
template<Size DIM>
Vector< bool, DIM > mi::math::operator^ (bool lhs, const Vector< bool, DIM > &rhs)
 Returns the elementwise logical xor of a bool and a boolean vector. More...
 
template<Size DIM>
Vector< bool, DIM > mi::math::operator^ (const Vector< bool, DIM > &lhs, bool rhs)
 Returns the elementwise logical xor of a boolean vector and a bool. More...
 
template<Size DIM>
Vector< bool, DIM > mi::math::operator! (const Vector< bool, DIM > &vec)
 Returns the elementwise logical not of a boolean vector. More...
 
template<typename T , Size DIM>
Vector< bool, DIM > mi::math::elementwise_is_equal (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Returns the boolean vector result of an elementwise equality comparison. More...
 
template<typename T , Size DIM>
Vector< bool, DIM > mi::math::elementwise_is_not_equal (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Returns the boolean vector result of an elementwise inequality comparison. More...
 
template<typename T , Size DIM>
Vector< bool, DIM > mi::math::elementwise_is_less_than (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Returns the boolean vector result of an elementwise less-than comparison. More...
 
template<typename T , Size DIM>
Vector< bool, DIM > mi::math::elementwise_is_less_than_or_equal (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Returns the boolean vector result of an elementwise less-than-or-equal comparison. More...
 
template<typename T , Size DIM>
Vector< bool, DIM > mi::math::elementwise_is_greater_than (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Returns the boolean vector result of an elementwise greater-than comparison. More...
 
template<typename T , Size DIM>
Vector< bool, DIM > mi::math::elementwise_is_greater_than_or_equal (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Returns the boolean vector result of an elementwise greater-than-or-equal comparison. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::abs (const Vector< T, DIM > &v)
 Returns a vector with the elementwise absolute values of the vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::acos (const Vector< T, DIM > &v)
 Returns a vector with the elementwise arc cosine of the vector v. More...
 
template<typename T , Size DIM>
bool mi::math::all (const Vector< T, DIM > &v)
 Returns true if all of all elements of v returns true. More...
 
template<typename T , Size DIM>
bool mi::math::any (const Vector< T, DIM > &v)
 Returns true if any of any element of v returns true. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::asin (const Vector< T, DIM > &v)
 Returns a vector with the elementwise arc sine of the vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::atan (const Vector< T, DIM > &v)
 Returns a vector with the elementwise arc tangent of the vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::atan2 (const Vector< T, DIM > &v, const Vector< T, DIM > &w)
 Returns a vector with the elementwise arc tangent of the vector v / w. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::ceil (const Vector< T, DIM > &v)
 Returns a vector with the elementwise smallest integral value that is not less than the element in vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::clamp (const Vector< T, DIM > &v, const Vector< T, DIM > &low, const Vector< T, DIM > &high)
 Returns the vector v elementwise clamped to the range [low, high]. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::clamp (const Vector< T, DIM > &v, const Vector< T, DIM > &low, T high)
 Returns the vector v elementwise clamped to the range [low, high]. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::clamp (const Vector< T, DIM > &v, T low, const Vector< T, DIM > &high)
 Returns the vector v elementwise clamped to the range [low, high]. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::clamp (const Vector< T, DIM > &v, T low, T high)
 Returns the vector v elementwise clamped to the range [low, high]. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::cos (const Vector< T, DIM > &v)
 Returns a vector with the elementwise cosine of the vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::degrees (const Vector< T, DIM > &v)
 Converts elementwise radians in v to degrees. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::elementwise_max (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Returns elementwise maximum of two vectors. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::elementwise_min (const Vector< T, DIM > &lhs, const Vector< T, DIM > &rhs)
 Returns elementwise minimum of two vectors. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::exp (const Vector< T, DIM > &v)
 Returns a vector with elementwise e to the power of the element in the vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::exp2 (const Vector< T, DIM > &v)
 Returns a vector with elementwise 2 to the power of the element in the vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::floor (const Vector< T, DIM > &v)
 Returns a vector with the elementwise largest integral value that is not greater than the element in vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::fmod (const Vector< T, DIM > &a, const Vector< T, DIM > &b)
 Returns elementwise a modulo b, in other words, the remainder of a/b. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::fmod (const Vector< T, DIM > &a, T b)
 Returns elementwise a modulo b, in other words, the remainder of a/b. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::frac (const Vector< T, DIM > &v)
 Returns a vector with the elementwise positive fractional part of the vector v. More...
 
template<typename T , Size DIM>
bool mi::math::is_approx_equal (const Vector< T, DIM > &left, const Vector< T, DIM > &right, T e)
 Compares the two given values elementwise for equality within the given epsilon. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::lerp (const Vector< T, DIM > &v1, const Vector< T, DIM > &v2, const Vector< T, DIM > &t)
 Returns the elementwise linear interpolation between v1 and v2, i.e., it returns (1-t) * v1 + t * v2. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::lerp (const Vector< T, DIM > &v1, const Vector< T, DIM > &v2, T t)
 Returns the linear interpolation between v1 and v2, i.e., it returns (1-t) * v1 + t * v2. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::log (const Vector< T, DIM > &v)
 Returns a vector with the elementwise natural logarithm of the vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::log2 (const Vector< T, DIM > &v)
 Returns a vector with the elementwise base 2 logarithm of the vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::log10 (const Vector< T, DIM > &v)
 Returns a vector with the elementwise base 10 logarithm of the vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::modf (const Vector< T, DIM > &v, Vector< T, DIM > &i)
 Returns the elementwise fractional part of v and stores the elementwise integral part of v in i. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::pow (const Vector< T, DIM > &a, const Vector< T, DIM > &b)
 Returns the vector a elementwise to the power of b. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::pow (const Vector< T, DIM > &a, T b)
 Returns the vector a elementwise to the power of b. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::radians (const Vector< T, DIM > &v)
 Converts elementwise degrees in v to radians. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::round (const Vector< T, DIM > &v)
 Returns a vector with the elements of vector v rounded to nearest integers. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::rsqrt (const Vector< T, DIM > &v)
 Returns the reciprocal of the square root of each element of v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::saturate (const Vector< T, DIM > &v)
 Returns the vector v clamped elementwise to the range [0,1]. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::sign (const Vector< T, DIM > &v)
 Returns the elementwise sign of vector v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::sin (const Vector< T, DIM > &v)
 Returns a vector with the elementwise sine of the vector v. More...
 
template<typename T , Size DIM>
void mi::math::sincos (const Vector< T, DIM > &a, Vector< T, DIM > &s, Vector< T, DIM > &c)
 Computes elementwise the sine s and cosine c of angles a simultaneously. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::smoothstep (const Vector< T, DIM > &a, const Vector< T, DIM > &b, const Vector< T, DIM > &v)
 Returns 0 if v is less than a and 1 if v is greater than b in an elementwise fashion. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::smoothstep (const Vector< T, DIM > &a, const Vector< T, DIM > &b, T x)
 Returns 0 if x is less than a and 1 if x is greater than b in an elementwise fashion. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::sqrt (const Vector< T, DIM > &v)
 Returns the square root of each element of v. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::step (const Vector< T, DIM > &a, const Vector< T, DIM > &v)
 Returns elementwise 0 if v is less than a and 1 otherwise. More...
 
template<typename T , Size DIM>
Vector< T, DIM > mi::math::tan (const Vector< T, DIM > &v)
 Returns a vector with the elementwise tangent of the vector v. More...
 
template<typename T >
mi::math::cross (const Vector< T, 2 > &lhs, const Vector< T, 2 > &rhs)
 Returns the two-times-two determinant result for the two vectors lhs and rhs. More...
 
template<typename T >
Vector< T, 3 > mi::math::cross (const Vector< T, 3 > &lhs, const Vector< T, 3 > &rhs)
 Returns the three-dimensional cross product result for the two vectors lhs and rhs. More...
 
template<typename T >
void mi::math::make_basis (const Vector< T, 3 > &n, Vector< T, 3 > *u, Vector< T, 3 > *v)
 Computes a basis of 3D space with one given vector. More...
 
template<typename T >
void mi::math::make_basis (const Vector< T, 3 > &n, const Vector< T, 3 > &u, const Vector< T, 3 > &v, Vector< T, 3 > *t, Vector< T, 3 > *b)
 Computes a basis of 3D space with one given vector, plane, and direction. More...
 
template<typename T2 , Size DIM2, typename T1 , Size DIM1>
Vector< T2, DIM2 > mi::math::convert_vector (const Vector< T1, DIM1 > &v, const T2 &fill=T2(0))
 Converts the vector v of type Vector<T1, DIM1> to a vector of type Vector<T2, DIM2>. More...
 

Detailed Description

Math vector class template of fixed dimension with arithmetic operators and generic functions.

See Math Vector Class.