Math API nvidia_logo_transpbg.gif Up
Internal Storage Class for Math Vector

Storage class for math vectors with support for x, y, z, and w members for appropriate dimensions. More...

Classes

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...
 

Typedefs

typedef Vector_struct<T, DIM> mi::math::Vector<T, DIM>::Pod_type
 POD class corresponding to this vector. More...
 
typedef Vector_struct<T, DIM> mi::math::Vector<T, DIM>::storage_type
 Storage class used by this vector. More...
 
typedef T mi::math::Vector<T, DIM>::value_type
 Element type. More...
 
typedef Size mi::math::Vector<T, DIM>::size_type
 Size type, unsigned. More...
 
typedef Difference mi::math::Vector<T, DIM>::difference_type
 Difference type, signed. More...
 
typedef T * mi::math::Vector<T, DIM>::pointer
 Mutable pointer to element. More...
 
typedef const T * mi::math::Vector<T, DIM>::const_pointer
 Const pointer to element. More...
 
typedef T & mi::math::Vector<T, DIM>::reference
 Mutable reference to element. More...
 
typedef const T & mi::math::Vector<T, DIM>::const_reference
 Const reference to element. 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...
 
static Size mi::math::Vector<T, DIM>::size ()
 Constant size of the vector. More...
 
static Size mi::math::Vector<T, DIM>::max_size ()
 Constant maximum size of the vector. More...
 
T * mi::math::Vector<T, DIM>::begin ()
 Returns the pointer to the first vector element. More...
 
const T * mi::math::Vector<T, DIM>::begin () const
 Returns the pointer to the first vector element. More...
 
T * mi::math::Vector<T, DIM>::end ()
 Returns the past-the-end pointer. More...
 
const T * mi::math::Vector<T, DIM>::end () const
 Returns the past-the-end pointer. More...
 
 mi::math::Vector<T, DIM>::Vector ()
 The default constructor leaves the vector elements uninitialized. More...
 
 mi::math::Vector<T, DIM>::Vector (const Vector<T, DIM> &vec)=default
 Default copy constructor. More...
 
 mi::math::Vector<T, DIM>::Vector (const Vector_struct<T, DIM> &vec)
 Constructor from underlying storage type. More...
 
 mi::math::Vector<T, DIM>::Vector (T v)
 Constructor initializes all vector elements to the value v. More...
 
template<typename Iterator>
 mi::math::Vector<T, DIM>::Vector (From_iterator_tag, Iterator p)
 Constructor requires the mi::math::FROM_ITERATOR tag as first argument and initializes the vector elements with the first DIM elements from the sequence starting at the iterator p. More...
 
template<typename T2>
 mi::math::Vector<T, DIM>::Vector (T2 const (&array)[DIM])
 Constructor initializes the vector elements from an array of dimension DIM. More...
 
template<typename T2>
 mi::math::Vector<T, DIM>::Vector (const Vector<T2, DIM> &other)
 Template constructor that allows explicit conversions from other vectors with assignment compatible element value type. More...
 
template<typename T2>
 mi::math::Vector<T, DIM>::Vector (const Vector_struct<T2, DIM> &other)
 Template constructor that allows explicit conversions from underlying storage type with assignment compatible element value type. More...
 
 mi::math::Vector<T, DIM>::Vector (T v1, T v2)
 Dedicated constructor, for dimension 2 only, that initializes the vector elements from the two elements (v1,v2). More...
 
 mi::math::Vector<T, DIM>::Vector (T v1, T v2, T v3)
 Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1,v2,v3). More...
 
 mi::math::Vector<T, DIM>::Vector (T v1, const Vector<T, 2> &v2)
 Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1,v2.x,v2.y). More...
 
 mi::math::Vector<T, DIM>::Vector (const Vector<T, 2> &v1, T v2)
 Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1.x,v1.y,v2). More...
 
 mi::math::Vector<T, DIM>::Vector (T v1, T v2, T v3, T v4)
 Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2,v3,v4). More...
 
 mi::math::Vector<T, DIM>::Vector (T v1, T v2, const Vector<T, 2> &v3)
 Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2,v3.x,v3.y). More...
 
 mi::math::Vector<T, DIM>::Vector (T v1, const Vector<T, 2> &v2, T v3)
 Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2.x,v2.y,v3). More...
 
 mi::math::Vector<T, DIM>::Vector (const Vector<T, 2> &v1, T v2, T v3)
 Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v2,v3). More...
 
 mi::math::Vector<T, DIM>::Vector (const Vector<T, 2> &v1, const Vector<T, 2> &v2)
 Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v2.x,v2.y). More...
 
 mi::math::Vector<T, DIM>::Vector (T v1, const Vector<T, 3> &v2)
 Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2.x,v2.y,v2.z). More...
 
 mi::math::Vector<T, DIM>::Vector (const Vector<T, 3> &v1, T v2)
 Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v1.z,v2). More...
 
 mi::math::Vector<T, DIM>::Vector (const Color_struct &color)
 Dedicated constructor, for dimension 4 only, that initializes the vector elements from a color interpreted as a vector (r,g,b,a). More...
 
Vectormi::math::Vector<T, DIM>::operator= (const Vector &other)=default
 Assignment. More...
 
Vectormi::math::Vector<T, DIM>::operator= (T s)
 Assignment from a scalar, setting all elements to s. More...
 
Vectormi::math::Vector<T, DIM>::operator= (const Color_struct &color)
 Assignment, for dimension 4 only, that assigns color interpreted as a vector (r,g,b,a) to this vector. More...
 
T & mi::math::Vector<T, DIM>::operator[] (Size i)
 Accesses the i-th vector element. More...
 
const T & mi::math::Vector<T, DIM>::operator[] (Size i) const
 Accesses the i-th vector element. More...
 
const T & mi::math::Vector<T, DIM>::get (Size i) const
 Returns the i-th vector element. More...
 
void mi::math::Vector<T, DIM>::set (Size i, T value)
 Sets the i-th vector element to value. More...
 
bool mi::math::Vector<T, DIM>::normalize ()
 Normalizes this vector to unit length. More...
 
bool mi::math::Vector<T, DIM>::operator== (Vector<T, DIM> rhs) const
 Returns true if lhs is elementwise equal to rhs. More...
 
bool mi::math::Vector<T, DIM>::operator!= (Vector<T, DIM> rhs) const
 Returns true if lhs is elementwise not equal to rhs. More...
 
bool mi::math::Vector<T, DIM>::operator< (Vector<T, DIM> rhs) const
 Returns true if lhs is lexicographically less than rhs. More...
 
bool mi::math::Vector<T, DIM>::operator<= (Vector<T, DIM> rhs) const
 Returns true if lhs is lexicographically less than or equal to rhs. More...
 
bool mi::math::Vector<T, DIM>::operator> (Vector<T, DIM> rhs) const
 Returns true if lhs is lexicographically greater than rhs. More...
 
bool mi::math::Vector<T, DIM>::operator>= (Vector<T, DIM> rhs) const
 Returns true if lhs is lexicographically greater than or equal to rhs. More...
 
template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator+= (Vector<T, DIM> &lhs, const Vector_struct<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_struct<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_struct<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_struct<T, DIM> &rhs)
 Computes lhs modulo rhs elementwise and returns the modified lhs. More...
 
template<typename T , typename U , Size DIM>
Vector<T, DIM> & mi::math::operator/= (Vector<T, DIM> &lhs, const Vector_struct<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_struct<T, DIM> &lhs, const Vector_struct<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_struct<T, DIM> &lhs, const Vector_struct<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_struct<T, DIM> &lhs, const Vector_struct<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_struct<T, DIM> &lhs, const Vector_struct<T, DIM> &rhs)
 Computes lhs modulo rhs elementwise and returns the new result. More...
 
template<typename T , typename U , Size DIM>
Vector<T, DIM> mi::math::operator/ (const Vector_struct<T, DIM> &lhs, const Vector_struct<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_struct<T, DIM> &v)
 Negates the vector v elementwise and returns the new result. 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. 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. 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_struct<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_struct<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_struct<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_struct<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_struct<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_struct<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_struct<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_struct<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_struct<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_struct<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_struct<T, DIM> &v, const Vector_struct<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_struct<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_struct<T, DIM> &v, const Vector_struct<T, DIM> &low, const Vector_struct<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_struct<T, DIM> &v, const Vector_struct<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_struct<T, DIM> &v, T low, const Vector_struct<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_struct<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_struct<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_struct<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_struct<T, DIM> &lhs, const Vector_struct<T, DIM> &rhs)
 Returns elementwise maximum of two vectors. More...
 
template<typename T , Size DIM>
Vector<T, DIM> mi::math::elementwise_min (const Vector_struct<T, DIM> &lhs, const Vector_struct<T, DIM> &rhs)
 Returns elementwise minimum of two vectors. More...
 
template<typename T , Size DIM>
Vector<T, DIM> mi::math::exp (const Vector_struct<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_struct<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_struct<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_struct<T, DIM> &a, const Vector_struct<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_struct<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_struct<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_struct<T, DIM> &left, const Vector_struct<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_struct<T, DIM> &v1, const Vector_struct<T, DIM> &v2, const Vector_struct<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_struct<T, DIM> &v1, const Vector_struct<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_struct<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_struct<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_struct<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_struct<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_struct<T, DIM> &a, const Vector_struct<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_struct<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_struct<T, DIM> &v)
 Converts elementwise degrees in v to radians. More...
 
template<typename T , Size DIM>
Vector<T, DIM> mi::math::round (const Vector_struct<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_struct<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_struct<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_struct<T, DIM> &v)
 Returns the elementwise sign of vector v. More...
 
template<typename T , Size DIM>
Vector<T, DIM> mi::math::sin (const Vector_struct<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_struct<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_struct<T, DIM> &a, const Vector_struct<T, DIM> &b, const Vector_struct<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_struct<T, DIM> &a, const Vector_struct<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_struct<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_struct<T, DIM> &a, const Vector_struct<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_struct<T, DIM> &v)
 Returns a vector with the elementwise tangent of the vector v. More...
 
template<typename T>
mi::math::cross (const Vector_struct<T, 2> &lhs, const Vector_struct<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_struct<T, 3> &lhs, const Vector_struct<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...
 

Variables

Float32 mi::math::Color_struct::r
 Red color component. More...
 
Float32 mi::math::Color_struct::g
 Green color component. More...
 
Float32 mi::math::Color_struct::b
 Blue color component. More...
 
Float32 mi::math::Color_struct::a
 Alpha value, 0.0 is fully transparent and 1.0 is opaque; value can lie outside that range. More...
 
mi::math::Vector_struct<T, DIM>::elements [DIM]
 coordinates. More...
 
mi::math::Vector_struct<T, 1>::x
 x-coordinate. More...
 
mi::math::Vector_struct<T, 2>::x
 x-coordinate. More...
 
mi::math::Vector_struct<T, 2>::y
 y-coordinate. More...
 
mi::math::Vector_struct<T, 3>::x
 x-coordinate. More...
 
mi::math::Vector_struct<T, 3>::y
 y-coordinate. More...
 
mi::math::Vector_struct<T, 3>::z
 z-coordinate. More...
 
mi::math::Vector_struct<T, 4>::x
 x-coordinate. More...
 
mi::math::Vector_struct<T, 4>::y
 y-coordinate. More...
 
mi::math::Vector_struct<T, 4>::z
 z-coordinate. More...
 
mi::math::Vector_struct<T, 4>::w
 w-coordinate. More...
 
static const Size mi::math::Vector<T, DIM>::DIMENSION = DIM
 Constant dimension of the vector. More...
 
static const Size mi::math::Vector<T, DIM>::SIZE = DIM
 Constant size of the vector. More...
 

Detailed Description

Storage class for math vectors with support for x, y, z, and w members for appropriate dimensions.

Use the mi::math::Vector template in your programs and this storage class only if you need a POD type, for example for parameter passing.

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

Typedef Documentation

 const_pointer

template<class T , Size DIM>
typedef const T* mi::math::Vector<T, DIM>::const_pointer

Const pointer to element.

 const_reference

template<class T , Size DIM>
typedef const T& mi::math::Vector<T, DIM>::const_reference

Const reference to element.

 difference_type

template<class T , Size DIM>
typedef Difference mi::math::Vector<T, DIM>::difference_type

Difference type, signed.

 Pod_type

template<class T , Size DIM>
typedef Vector_struct<T,DIM> mi::math::Vector<T, DIM>::Pod_type

POD class corresponding to this vector.

 pointer

template<class T , Size DIM>
typedef T* mi::math::Vector<T, DIM>::pointer

Mutable pointer to element.

 reference

template<class T , Size DIM>
typedef T& mi::math::Vector<T, DIM>::reference

Mutable reference to element.

 size_type

template<class T , Size DIM>
typedef Size mi::math::Vector<T, DIM>::size_type

Size type, unsigned.

 storage_type

template<class T , Size DIM>
typedef Vector_struct<T,DIM> mi::math::Vector<T, DIM>::storage_type

Storage class used by this vector.

 value_type

template<class T , Size DIM>
typedef T mi::math::Vector<T, DIM>::value_type

Element type.

Function Documentation

 abs()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::abs ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise absolute values of the vector v.

 acos()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::acos ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise arc cosine of the vector v.

 all()

template<typename T , Size DIM>
bool mi::math::all ( const Vector_struct<T, DIM> &  v)
inline

Returns true if all of all elements of v returns true.

 any()

template<typename T , Size DIM>
bool mi::math::any ( const Vector_struct<T, DIM> &  v)
inline

Returns true if any of any element of v returns true.

 asin()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::asin ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise arc sine of the vector v.

 atan()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::atan ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise arc tangent of the vector v.

 atan2()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::atan2 ( const Vector_struct<T, DIM> &  v,
const Vector_struct<T, DIM> &  w 
)
inline

Returns a vector with the elementwise arc tangent of the vector v / w.

The signs of the elements of v and w are used to determine the quadrant of the results.

 begin() [1/2]

template<class T , Size DIM>
T * mi::math::Vector<T, DIM>::begin ( )
inline

Returns the pointer to the first vector element.

 begin() [2/2]

template<class T , Size DIM>
const T * mi::math::Vector<T, DIM>::begin ( ) const
inline

Returns the pointer to the first vector element.

 ceil()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::ceil ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise smallest integral value that is not less than the element in vector v.

 clamp() [1/4]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::clamp ( const Vector_struct<T, DIM> &  v,
const Vector_struct<T, DIM> &  low,
const Vector_struct<T, DIM> &  high 
)
inline

Returns the vector v elementwise clamped to the range [low, high].

 clamp() [2/4]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::clamp ( const Vector_struct<T, DIM> &  v,
const Vector_struct<T, DIM> &  low,
high 
)
inline

Returns the vector v elementwise clamped to the range [low, high].

 clamp() [3/4]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::clamp ( const Vector_struct<T, DIM> &  v,
low,
const Vector_struct<T, DIM> &  high 
)
inline

Returns the vector v elementwise clamped to the range [low, high].

 clamp() [4/4]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::clamp ( const Vector_struct<T, DIM> &  v,
low,
high 
)
inline

Returns the vector v elementwise clamped to the range [low, high].

 convert_vector()

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) 
)
inline

Converts the vector v of type Vector<T1, DIM1> to a vector of type Vector<T2, DIM2>.

If DIM1 < DIM2, the remaining values are filled with fill. If DIM1 > DIM2, the values that do not fit into the result vector are discarded. The conversion from T1 to T2 must be possible.

 cos()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::cos ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise cosine of the vector v.

 cross() [1/2]

template<typename T>
T mi::math::cross ( const Vector_struct<T, 2> &  lhs,
const Vector_struct<T, 2> &  rhs 
)
inline

Returns the two-times-two determinant result for the two vectors lhs and rhs.

 cross() [2/2]

template<typename T>
Vector<T, 3> mi::math::cross ( const Vector_struct<T, 3> &  lhs,
const Vector_struct<T, 3> &  rhs 
)
inline

Returns the three-dimensional cross product result for the two vectors lhs and rhs.

 degrees()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::degrees ( const Vector_struct<T, DIM> &  v)
inline

Converts elementwise radians in v to degrees.

 elementwise_is_equal()

template<typename T , Size DIM>
Vector<bool, DIM> mi::math::elementwise_is_equal ( const Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Returns the boolean vector result of an elementwise equality comparison.

 elementwise_is_greater_than()

template<typename T , Size DIM>
Vector<bool, DIM> mi::math::elementwise_is_greater_than ( const Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Returns the boolean vector result of an elementwise greater-than comparison.

 elementwise_is_greater_than_or_equal()

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 
)
inline

Returns the boolean vector result of an elementwise greater-than-or-equal comparison.

 elementwise_is_less_than()

template<typename T , Size DIM>
Vector<bool, DIM> mi::math::elementwise_is_less_than ( const Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Returns the boolean vector result of an elementwise less-than comparison.

 elementwise_is_less_than_or_equal()

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 
)
inline

Returns the boolean vector result of an elementwise less-than-or-equal comparison.

 elementwise_is_not_equal()

template<typename T , Size DIM>
Vector<bool, DIM> mi::math::elementwise_is_not_equal ( const Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Returns the boolean vector result of an elementwise inequality comparison.

 elementwise_max()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::elementwise_max ( const Vector_struct<T, DIM> &  lhs,
const Vector_struct<T, DIM> &  rhs 
)
inline

Returns elementwise maximum of two vectors.

 elementwise_min()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::elementwise_min ( const Vector_struct<T, DIM> &  lhs,
const Vector_struct<T, DIM> &  rhs 
)
inline

Returns elementwise minimum of two vectors.

 end() [1/2]

template<class T , Size DIM>
T * mi::math::Vector<T, DIM>::end ( )
inline

Returns the past-the-end pointer.

The range [begin(),end()) forms the range over all vector elements.

 end() [2/2]

template<class T , Size DIM>
const T * mi::math::Vector<T, DIM>::end ( ) const
inline

Returns the past-the-end pointer.

The range [begin(),end()) forms the range over all vector elements.

 exp()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::exp ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with elementwise e to the power of the element in the vector v.

 exp2()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::exp2 ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with elementwise 2 to the power of the element in the vector v.

 floor()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::floor ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise largest integral value that is not greater than the element in vector v.

 fmod() [1/2]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::fmod ( const Vector_struct<T, DIM> &  a,
const Vector_struct<T, DIM> &  b 
)
inline

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

The elementwise result has the same sign as a.

 fmod() [2/2]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::fmod ( const Vector_struct<T, DIM> &  a,
b 
)
inline

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

The elementwise result has the same sign as a.

 frac()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::frac ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise positive fractional part of the vector v.

 get()

template<class T , Size DIM>
const T & mi::math::Vector<T, DIM>::get ( Size  i) const
inline

Returns the i-th vector element.

Precondition
0 <= i < size()

 is_approx_equal()

template<typename T , Size DIM>
bool mi::math::is_approx_equal ( const Vector_struct<T, DIM> &  left,
const Vector_struct<T, DIM> &  right,
e 
)
inline

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

 lerp() [1/2]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::lerp ( const Vector_struct<T, DIM> &  v1,
const Vector_struct<T, DIM> &  v2,
const Vector_struct<T, DIM> &  t 
)
inline

Returns the elementwise linear interpolation between v1 and v2, i.e., it returns (1-t) * v1 + t * v2.

Parameters
v1one vector
v2second vector
tinterpolation parameter in [0,1]

 lerp() [2/2]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::lerp ( const Vector_struct<T, DIM> &  v1,
const Vector_struct<T, DIM> &  v2,
t 
)
inline

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

Parameters
v1one vector
v2second vector
tinterpolation parameter in [0,1]

 log()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::log ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise natural logarithm of the vector v.

 log10()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::log10 ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise base 10 logarithm of the vector v.

 log2()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::log2 ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise base 2 logarithm of the vector v.

 make_basis() [1/2]

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 
)
inline

Computes a basis of 3D space with one given vector, plane, and direction.

Given a unit length vector n, and two non-colinear and non-zero vectors u and v, this function computes two vectors t and b such that (t, n, b) forms an orthonormal basis (t and b are unit length), t lies in the plane formed by n and u, and b has the same orientation as v, i.e., dot(b, v) >= 0.

Parameters
ninput, normal vector
uinput, first direction vector
vinput, second direction vector
toutput, first vector in tangent plane
boutput, second vector in tangent plane

 make_basis() [2/2]

template<typename T>
void mi::math::make_basis ( const Vector<T, 3> &  n,
Vector<T, 3> *  u,
Vector<T, 3> *  v 
)
inline

Computes a basis of 3D space with one given vector.

Given a unit length vector n, computes two vectors u and v such that (u, n, v) forms an orthonormal basis (u and v are unit length). This function is not continuous with respect to n: in some cases, a small perturbation on n will flip the basis.

Parameters
ninput, normal vector
uoutput, first vector in tangent plane
voutput, second vector in tangent plane

 max_size()

template<class T , Size DIM>
static Size mi::math::Vector<T, DIM>::max_size ( )
inlinestatic

Constant maximum size of the vector.

 modf()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::modf ( const Vector_struct<T, DIM> &  v,
Vector<T, DIM> &  i 
)
inline

Returns the elementwise fractional part of v and stores the elementwise integral part of v in i.

Both parts have elementwise the same sign as v.

 normalize()

template<class T , Size DIM>
bool mi::math::Vector<T, DIM>::normalize ( )
inline

Normalizes this vector to unit length.

Returns false if normalization fails because the vector norm is zero, and true otherwise. This vector remains unchanged if normalization failed.

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

 operator!()

template<Size DIM>
Vector<bool, DIM> mi::math::operator! ( const Vector<bool, DIM> &  vec)
inline

Returns the elementwise logical not of a boolean vector.

 operator!=()

template<class T , Size DIM>
bool mi::math::Vector<T, DIM>::operator!= ( Vector<T, DIM>  rhs) const
inline

Returns true if lhs is elementwise not equal to rhs.

 operator%() [1/3]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::operator% ( const Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Computes lhs modulo rhs elementwise and returns the new result.

Only defined for typenames T having the % operator.

 operator%() [2/3]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::operator% ( const Vector_struct<T, DIM> &  lhs,
const Vector_struct<T, DIM> &  rhs 
)
inline

Computes lhs modulo rhs elementwise and returns the new result.

Only defined for typenames T having the % operator.

 operator%() [3/3]

template<typename T , typename TT , Size DIM>
Vector<T, DIM> mi::math::operator% ( const Vector_struct<T, DIM> &  v,
TT  s 
)
inline

Computes v modulo s elementwise and returns the new result.

Only defined for typenames T having the % operator for TT arguments.

 operator%=() [1/3]

template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator%= ( Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Computes lhs modulo rhs elementwise and returns the modified lhs.

Only defined for typenames T having the % operator.

 operator%=() [2/3]

template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator%= ( Vector<T, DIM> &  lhs,
const Vector_struct<T, DIM> &  rhs 
)
inline

Computes lhs modulo rhs elementwise and returns the modified lhs.

Only defined for typenames T having the % operator.

 operator%=() [3/3]

template<typename T , typename TT , Size DIM>
Vector<T, DIM> & mi::math::operator%= ( Vector<T, DIM> &  v,
TT  s 
)
inline

Computes v modulo s elementwise and returns the modified vector v.

Only defined for typenames T having the % operator for TT arguments.

 operator&&() [1/3]

template<Size DIM>
Vector<bool, DIM> mi::math::operator&& ( bool  lhs,
const Vector<bool, DIM> &  rhs 
)
inline

Returns the elementwise logical and of a bool and a boolean vector.

 operator&&() [2/3]

template<Size DIM>
Vector<bool, DIM> mi::math::operator&& ( const Vector<bool, DIM> &  lhs,
bool  rhs 
)
inline

Returns the elementwise logical and of a boolean vector and a bool.

 operator&&() [3/3]

template<Size DIM>
Vector<bool, DIM> mi::math::operator&& ( const Vector<bool, DIM> &  lhs,
const Vector<bool, DIM> &  rhs 
)
inline

Returns the elementwise logical and of two boolean vectors.

 operator*() [1/4]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::operator* ( const Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Multiplies rhs elementwise with lhs and returns the new result.

 operator*() [2/4]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::operator* ( const Vector_struct<T, DIM> &  lhs,
const Vector_struct<T, DIM> &  rhs 
)
inline

Multiplies rhs elementwise with lhs and returns the new result.

 operator*() [3/4]

template<typename T , typename TT , Size DIM>
Vector<T, DIM> mi::math::operator* ( const Vector_struct<T, DIM> &  v,
TT  s 
)
inline

Multiplies the vector v elementwise with the scalar s and returns the new result.

 operator*() [4/4]

template<typename T , typename TT , Size DIM>
Vector<T, DIM> mi::math::operator* ( TT  s,
const Vector_struct<T, DIM> &  v 
)
inline

Multiplies the vector v elementwise with the scalar s and returns the new result.

 operator*=() [1/3]

template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator*= ( Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Multiplies rhs elementwise with lhs and returns the modified lhs.

 operator*=() [2/3]

template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator*= ( Vector<T, DIM> &  lhs,
const Vector_struct<T, DIM> &  rhs 
)
inline

Multiplies rhs elementwise with lhs and returns the modified lhs.

 operator*=() [3/3]

template<typename T , typename TT , Size DIM>
Vector<T, DIM> & mi::math::operator*= ( Vector<T, DIM> &  v,
TT  s 
)
inline

Multiplies the vector v elementwise with the scalar s and returns the modified vector v.

 operator+() [1/2]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::operator+ ( const Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Adds lhs and rhs elementwise and returns the new result.

 operator+() [2/2]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::operator+ ( const Vector_struct<T, DIM> &  lhs,
const Vector_struct<T, DIM> &  rhs 
)
inline

Adds lhs and rhs elementwise and returns the new result.

 operator++()

template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator++ ( Vector<T, DIM> &  vec)
inline

Pre-increments all elements of vec and returns the result. Modifies vec.

 operator+=() [1/2]

template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator+= ( Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Adds rhs elementwise to lhs and returns the modified lhs.

 operator+=() [2/2]

template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator+= ( Vector<T, DIM> &  lhs,
const Vector_struct<T, DIM> &  rhs 
)
inline

Adds rhs elementwise to lhs and returns the modified lhs.

 operator-() [1/4]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::operator- ( const Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Subtracts rhs elementwise from lhs and returns the new result.

 operator-() [2/4]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::operator- ( const Vector<T, DIM> &  v)
inline

Negates the vector v elementwise and returns the new result.

 operator-() [3/4]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::operator- ( const Vector_struct<T, DIM> &  lhs,
const Vector_struct<T, DIM> &  rhs 
)
inline

Subtracts rhs elementwise from lhs and returns the new result.

 operator-() [4/4]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::operator- ( const Vector_struct<T, DIM> &  v)
inline

Negates the vector v elementwise and returns the new result.

 operator--()

template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator-- ( Vector<T, DIM> &  vec)
inline

Pre-decrements all elements of vec and returns the result. Modifies vec.

 operator-=() [1/2]

template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator-= ( Vector<T, DIM> &  lhs,
const Vector<T, DIM> &  rhs 
)
inline

Subtracts rhs elementwise from lhs and returns the modified lhs.

 operator-=() [2/2]

template<typename T , Size DIM>
Vector<T, DIM> & mi::math::operator-= ( Vector<T, DIM> &  lhs,
const Vector_struct<T, DIM> &  rhs 
)
inline

Subtracts rhs elementwise from lhs and returns the modified lhs.

 operator/() [1/3]

template<typename T , typename U , Size DIM>
Vector<T, DIM> mi::math::operator/ ( const Vector<T, DIM> &  lhs,
const Vector<U, DIM> &  rhs 
)
inline

Divides rhs elementwise by lhs and returns the new result.

 operator/() [2/3]

template<typename T , typename U , Size DIM>
Vector<T, DIM> mi::math::operator/ ( const Vector_struct<T, DIM> &  lhs,
const Vector_struct<U, DIM> &  rhs 
)
inline

Divides rhs elementwise by lhs and returns the new result.

 operator/() [3/3]

template<typename T , typename TT , Size DIM>
Vector<T, DIM> mi::math::operator/ ( const Vector_struct<T, DIM> &  v,
TT  s 
)
inline

Divides the vector v elementwise by the scalar s and returns the new result.

 operator/=() [1/3]

template<typename T , typename U , Size DIM>
Vector<T, DIM> & mi::math::operator/= ( Vector<T, DIM> &  lhs,
const Vector<U, DIM> &  rhs 
)
inline

Divides lhs elementwise by rhs and returns the modified lhs.

 operator/=() [2/3]

template<typename T , typename U , Size DIM>
Vector<T, DIM> & mi::math::operator/= ( Vector<T, DIM> &  lhs,
const Vector_struct<U, DIM> &  rhs 
)
inline

Divides lhs elementwise by rhs and returns the modified lhs.

 operator/=() [3/3]

template<typename T , typename TT , Size DIM>
Vector<T, DIM> & mi::math::operator/= ( Vector<T, DIM> &  v,
TT  s 
)
inline

Divides the vector v elementwise by the scalar s and returns the modified vector v.

 operator<()

template<class T , Size DIM>
bool mi::math::Vector<T, DIM>::operator< ( Vector<T, DIM>  rhs) const
inline

Returns true if lhs is lexicographically less than rhs.

See also
Definition: Lexicographic order and comparison

 operator<=()

template<class T , Size DIM>
bool mi::math::Vector<T, DIM>::operator<= ( Vector<T, DIM>  rhs) const
inline

Returns true if lhs is lexicographically less than or equal to rhs.

See also
Definition: Lexicographic order and comparison

 operator=() [1/3]

template<class T , Size DIM>
Vector & mi::math::Vector<T, DIM>::operator= ( const Color_struct color)
inline

Assignment, for dimension 4 only, that assigns color interpreted as a vector (r,g,b,a) to this vector.

Precondition
DIM == 4

 operator=() [2/3]

template<class T , Size DIM>
Vector & mi::math::Vector<T, DIM>::operator= ( const Vector<T, DIM> &  other)
default

Assignment.

 operator=() [3/3]

template<class T , Size DIM>
Vector & mi::math::Vector<T, DIM>::operator= ( s)
inline

Assignment from a scalar, setting all elements to s.

 operator==()

template<class T , Size DIM>
bool mi::math::Vector<T, DIM>::operator== ( Vector<T, DIM>  rhs) const
inline

Returns true if lhs is elementwise equal to rhs.

 operator>()

template<class T , Size DIM>
bool mi::math::Vector<T, DIM>::operator> ( Vector<T, DIM>  rhs) const
inline

Returns true if lhs is lexicographically greater than rhs.

See also
Definition: Lexicographic order and comparison

 operator>=()

template<class T , Size DIM>
bool mi::math::Vector<T, DIM>::operator>= ( Vector<T, DIM>  rhs) const
inline

Returns true if lhs is lexicographically greater than or equal to rhs.

See also
Definition: Lexicographic order and comparison

 operator[]() [1/2]

template<class T , Size DIM>
T & mi::math::Vector<T, DIM>::operator[] ( Size  i)
inline

Accesses the i-th vector element.

Precondition
0 <= i < size()

 operator[]() [2/2]

template<class T , Size DIM>
const T & mi::math::Vector<T, DIM>::operator[] ( Size  i) const
inline

Accesses the i-th vector element.

Precondition
0 <= i < size()

 operator^() [1/3]

template<Size DIM>
Vector<bool, DIM> mi::math::operator^ ( bool  lhs,
const Vector<bool, DIM> &  rhs 
)
inline

Returns the elementwise logical xor of a bool and a boolean vector.

 operator^() [2/3]

template<Size DIM>
Vector<bool, DIM> mi::math::operator^ ( const Vector<bool, DIM> &  lhs,
bool  rhs 
)
inline

Returns the elementwise logical xor of a boolean vector and a bool.

 operator^() [3/3]

template<Size DIM>
Vector<bool, DIM> mi::math::operator^ ( const Vector<bool, DIM> &  lhs,
const Vector<bool, DIM> &  rhs 
)
inline

Returns the elementwise logical xor of two boolean vectors.

 operator||() [1/3]

template<Size DIM>
Vector<bool, DIM> mi::math::operator|| ( bool  lhs,
const Vector<bool, DIM> &  rhs 
)
inline

Returns the elementwise logical or of a bool and a boolean vector.

 operator||() [2/3]

template<Size DIM>
Vector<bool, DIM> mi::math::operator|| ( const Vector<bool, DIM> &  lhs,
bool  rhs 
)
inline

Returns the elementwise logical or of a boolean vector and a bool.

 operator||() [3/3]

template<Size DIM>
Vector<bool, DIM> mi::math::operator|| ( const Vector<bool, DIM> &  lhs,
const Vector<bool, DIM> &  rhs 
)
inline

Returns the elementwise logical or of two boolean vectors.

 pow() [1/2]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::pow ( const Vector_struct<T, DIM> &  a,
const Vector_struct<T, DIM> &  b 
)
inline

Returns the vector a elementwise to the power of b.

 pow() [2/2]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::pow ( const Vector_struct<T, DIM> &  a,
b 
)
inline

Returns the vector a elementwise to the power of b.

 radians()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::radians ( const Vector_struct<T, DIM> &  v)
inline

Converts elementwise degrees in v to radians.

 round()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::round ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elements of vector v rounded to nearest integers.

 rsqrt()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::rsqrt ( const Vector_struct<T, DIM> &  v)
inline

Returns the reciprocal of the square root of each element of v.

 saturate()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::saturate ( const Vector_struct<T, DIM> &  v)
inline

Returns the vector v clamped elementwise to the range [0,1].

 set()

template<class T , Size DIM>
void mi::math::Vector<T, DIM>::set ( Size  i,
value 
)
inline

Sets the i-th vector element to value.

Precondition
0 <= i < size()

 sign()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::sign ( const Vector_struct<T, DIM> &  v)
inline

Returns the elementwise sign of vector v.

 sin()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::sin ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise sine of the vector v.

 sincos()

template<typename T , Size DIM>
void mi::math::sincos ( const Vector_struct<T, DIM> &  a,
Vector<T, DIM> &  s,
Vector<T, DIM> &  c 
)
inline

Computes elementwise the sine s and cosine c of angles a simultaneously.

The angles a are specified in radians.

 size()

template<class T , Size DIM>
static Size mi::math::Vector<T, DIM>::size ( )
inlinestatic

Constant size of the vector.

 smoothstep() [1/2]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::smoothstep ( const Vector_struct<T, DIM> &  a,
const Vector_struct<T, DIM> &  b,
const Vector_struct<T, DIM> &  v 
)
inline

Returns 0 if v is less than a and 1 if v is greater than b in an elementwise fashion.

A smooth curve is applied in-between so that the return values vary continuously from 0 to 1 as elements in v vary from a to b.

 smoothstep() [2/2]

template<typename T , Size DIM>
Vector<T, DIM> mi::math::smoothstep ( const Vector_struct<T, DIM> &  a,
const Vector_struct<T, DIM> &  b,
x 
)
inline

Returns 0 if x is less than a and 1 if x is greater than b in an elementwise fashion.

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

 sqrt()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::sqrt ( const Vector_struct<T, DIM> &  v)
inline

Returns the square root of each element of v.

 step()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::step ( const Vector_struct<T, DIM> &  a,
const Vector_struct<T, DIM> &  v 
)
inline

Returns elementwise 0 if v is less than a and 1 otherwise.

 tan()

template<typename T , Size DIM>
Vector<T, DIM> mi::math::tan ( const Vector_struct<T, DIM> &  v)
inline

Returns a vector with the elementwise tangent of the vector v.

 Vector() [1/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( )
inline

The default constructor leaves the vector elements uninitialized.

 Vector() [2/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( const Color_struct color)
inlineexplicit

Dedicated constructor, for dimension 4 only, that initializes the vector elements from a color interpreted as a vector (r,g,b,a).

Precondition
DIM == 4

 Vector() [3/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( const Vector<T, 2> &  v1,
const Vector<T, 2> &  v2 
)
inline

Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v2.x,v2.y).

Precondition
DIM == 4

 Vector() [4/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( const Vector<T, 2> &  v1,
v2 
)
inline

Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1.x,v1.y,v2).

Precondition
DIM == 3

 Vector() [5/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( const Vector<T, 2> &  v1,
v2,
v3 
)
inline

Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v2,v3).

Precondition
DIM == 4

 Vector() [6/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( const Vector<T, 3> &  v1,
v2 
)
inline

Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v1.z,v2).

Precondition
DIM == 4

 Vector() [7/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( const Vector<T, DIM> &  vec)
default

Default copy constructor.

 Vector() [8/20]

template<class T , Size DIM>
template<typename T2>
mi::math::Vector<T, DIM>::Vector ( const Vector<T2, DIM> &  other)
inlineexplicit

Template constructor that allows explicit conversions from other vectors with assignment compatible element value type.

 Vector() [9/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( const Vector_struct<T, DIM> &  vec)
inline

Constructor from underlying storage type.

 Vector() [10/20]

template<class T , Size DIM>
template<typename T2>
mi::math::Vector<T, DIM>::Vector ( const Vector_struct<T2, DIM> &  other)
inlineexplicit

Template constructor that allows explicit conversions from underlying storage type with assignment compatible element value type.

 Vector() [11/20]

template<class T , Size DIM>
template<typename Iterator>
mi::math::Vector<T, DIM>::Vector ( From_iterator_tag  ,
Iterator  p 
)
inline

Constructor requires the mi::math::FROM_ITERATOR tag as first argument and initializes the vector elements with the first DIM elements from the sequence starting at the iterator p.

Iterator must be a model of an input iterator. The value type of Iterator must be assignment compatible with the vector elements type T.

An example:

std::vector<int> data( 10, 42); // ten elements of value 42
Fixed-size math vector class template with generic operations.
Definition: vector.h:286
@ FROM_ITERATOR
Unique enumerator of From_iterator_tag.
Definition: vector.h:37

 Vector() [12/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( v)
inlineexplicit

Constructor initializes all vector elements to the value v.

 Vector() [13/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( v1,
const Vector<T, 2> &  v2 
)
inline

Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1,v2.x,v2.y).

Precondition
DIM == 3

 Vector() [14/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( v1,
const Vector<T, 2> &  v2,
v3 
)
inline

Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2.x,v2.y,v3).

Precondition
DIM == 4

 Vector() [15/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( v1,
const Vector<T, 3> &  v2 
)
inline

Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2.x,v2.y,v2.z).

Precondition
DIM == 4

 Vector() [16/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( v1,
v2 
)
inline

Dedicated constructor, for dimension 2 only, that initializes the vector elements from the two elements (v1,v2).

Precondition
DIM == 2

 Vector() [17/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( v1,
v2,
const Vector<T, 2> &  v3 
)
inline

Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2,v3.x,v3.y).

Precondition
DIM == 4

 Vector() [18/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( v1,
v2,
v3 
)
inline

Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1,v2,v3).

Precondition
DIM == 3

 Vector() [19/20]

template<class T , Size DIM>
mi::math::Vector<T, DIM>::Vector ( v1,
v2,
v3,
v4 
)
inline

Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2,v3,v4).

Precondition
DIM == 4

 Vector() [20/20]

template<class T , Size DIM>
template<typename T2>
mi::math::Vector<T, DIM>::Vector ( T2 const (&)  array[DIM])
inlineexplicit

Constructor initializes the vector elements from an array of dimension DIM.

The value type T2 of the array must be assignment compatible with the vector elements type T.

An example:

int data[3] = { 1, 2, 4};

 vector_base_ptr() [1/10]

template<typename T>
const T * mi::math::vector_base_ptr ( const Vector_struct<T, 1> &  vec)
inline

Returns the base pointer to the vector data, specialization for DIM==1.

 vector_base_ptr() [2/10]

template<typename T>
const T * mi::math::vector_base_ptr ( const Vector_struct<T, 2> &  vec)
inline

Returns the base pointer to the vector data, specialization for DIM==2.

 vector_base_ptr() [3/10]

template<typename T>
const T * mi::math::vector_base_ptr ( const Vector_struct<T, 3> &  vec)
inline

Returns the base pointer to the vector data, specialization for DIM==3.

 vector_base_ptr() [4/10]

template<typename T>
const T * mi::math::vector_base_ptr ( const Vector_struct<T, 4> &  vec)
inline

Returns the base pointer to the vector data, specialization for DIM==4.

 vector_base_ptr() [5/10]

template<typename T , Size DIM>
const T * mi::math::vector_base_ptr ( const Vector_struct<T, DIM> &  vec)
inline

Returns the base pointer to the vector data.

 vector_base_ptr() [6/10]

template<typename T>
T * mi::math::vector_base_ptr ( Vector_struct<T, 1> &  vec)
inline

Returns the base pointer to the vector data, specialization for DIM==1.

 vector_base_ptr() [7/10]

template<typename T>
T * mi::math::vector_base_ptr ( Vector_struct<T, 2> &  vec)
inline

Returns the base pointer to the vector data, specialization for DIM==2.

 vector_base_ptr() [8/10]

template<typename T>
T * mi::math::vector_base_ptr ( Vector_struct<T, 3> &  vec)
inline

Returns the base pointer to the vector data, specialization for DIM==3.

 vector_base_ptr() [9/10]

template<typename T>
T * mi::math::vector_base_ptr ( Vector_struct<T, 4> &  vec)
inline

Returns the base pointer to the vector data, specialization for DIM==4.

 vector_base_ptr() [10/10]

template<typename T , Size DIM>
T * mi::math::vector_base_ptr ( Vector_struct<T, DIM> &  vec)
inline

Returns the base pointer to the vector data.

Variable Documentation

 a

Float32 mi::math::Color_struct::a

Alpha value, 0.0 is fully transparent and 1.0 is opaque; value can lie outside that range.

 b

Float32 mi::math::Color_struct::b

Blue color component.

 DIMENSION

template<class T , Size DIM>
const Size mi::math::Vector<T, DIM>::DIMENSION = DIM
static

Constant dimension of the vector.

 elements

template<typename T , Size DIM>
T mi::math::Vector_struct<T, DIM>::elements[DIM]

coordinates.

 g

Float32 mi::math::Color_struct::g

Green color component.

 r

Float32 mi::math::Color_struct::r

Red color component.

 SIZE

template<class T , Size DIM>
const Size mi::math::Vector<T, DIM>::SIZE = DIM
static

Constant size of the vector.

 w

template<typename T>
T mi::math::Vector_struct<T, 4>::w

w-coordinate.

 x [1/4]

template<typename T>
T mi::math::Vector_struct<T, 1>::x

x-coordinate.

 x [2/4]

template<typename T>
T mi::math::Vector_struct<T, 2>::x

x-coordinate.

 x [3/4]

template<typename T>
T mi::math::Vector_struct<T, 3>::x

x-coordinate.

 x [4/4]

template<typename T>
T mi::math::Vector_struct<T, 4>::x

x-coordinate.

 y [1/3]

template<typename T>
T mi::math::Vector_struct<T, 2>::y

y-coordinate.

 y [2/3]

template<typename T>
T mi::math::Vector_struct<T, 3>::y

y-coordinate.

 y [3/3]

template<typename T>
T mi::math::Vector_struct<T, 4>::y

y-coordinate.

 z [1/2]

template<typename T>
T mi::math::Vector_struct<T, 3>::z

z-coordinate.

 z [2/2]

template<typename T>
T mi::math::Vector_struct<T, 4>::z

z-coordinate.