neuray API Programmer's Manual

Math Vector Class

[Math API]

Description

Math vector class template of fixed dimension with generic operations.

Include File:

#include <mi/math/vector.h>

Modules

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

Classes

class 
Fixed-size math vector class template with generic operations. More...

Functions

template< typename T, Size> Vector < T , DIM > mi::math::abs( const Vector_struct < T , DIM >& v)
Returns a vector with the elementwise absolute values of the vector v.
template< typename T, Size> Vector < T , DIM > mi::math::acos( const Vector_struct < T , DIM >& v)
Returns a vector with the elementwise arc cosine of the vector v.
template< typename T, Size>bool  mi::math::all( const Vector_struct < T , DIM >& v)
Returns true if all of all elements of v returns true.
template< typename T, Size>bool  mi::math::any( const Vector_struct < T , DIM >& v)
Returns true if any of any element of v returns true.
template< typename T, Size> Vector < T , DIM > mi::math::asin( const Vector_struct < T , DIM >& v)
Returns a vector with the elementwise arc sine of the vector v.
template< typename T, Size> Vector < T , DIM > mi::math::atan( const Vector_struct < T , DIM >& v)
Returns a vector with the elementwise arc tangent of the vector v.
template< typename T, Size> 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> 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.
template< typename T, Size> 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].
template< typename T, Size> 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].
template< typename T, Size> 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].
template< typename T, Size> 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].
template< typename T2, Size, typename T1, Size> 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...
template< typename T, Size> Vector < T , DIM > mi::math::cos( const Vector_struct < T , DIM >& v)
Returns a vector with the elementwise cosine of the vector v.
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.
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.
template< typename T, Size> Vector < T , DIM > mi::math::degrees( const Vector_struct < T , DIM >& v)
Converts elementwise radians in v to degrees.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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> 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> 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.
template< typename T, Size>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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> Vector < T , DIM > mi::math::log( const Vector_struct < T , DIM >& v)
Returns a vector with the elementwise natural logarithm of the vector v.
template< typename T, Size> 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.
template< typename T, Size> 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.
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 T, Size> 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< Size> Vector < bool , DIM > mi::math::operator!( const Vector < bool , DIM >& vec)
Returns the elementwise logical not of a boolean vector.
template< typename T, Size> 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, Size> 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 TT, Size> 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, Size> 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, Size> 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 TT, Size> 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< Size> 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.
template< Size> 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.
template< Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, typename TT, Size> 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.
template< typename T, typename TT, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, typename TT, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> Vector < T , DIM >& mi::math::operator++( Vector < T , DIM >& vec)
Pre-increments all elements of vec and returns the result. Modifies vec.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, Size> Vector < T , DIM > mi::math::operator-( const Vector_struct < T , DIM >& v)
Negates the vector v elementwise and returns the new result.
template< typename T, Size> 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.
template< typename T, Size> Vector < T , DIM > mi::math::operator-( const Vector < T , DIM >& v)
Negates the vector v elementwise and returns the new result.
template< typename T, Size> Vector < T , DIM >& mi::math::operator--( Vector < T , DIM >& vec)
Pre-decrements all elements of vec and returns the result. Modifies vec.
template< typename T, Size> 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.
template< typename T, Size> 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.
template< typename T, typename U, Size> 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.
template< typename T, typename U, Size> 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.
template< typename T, typename TT, Size> 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.
template< typename T, typename U, Size> 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.
template< typename T, typename U, Size> 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.
template< typename T, typename TT, Size> 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.
template< Size> 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.
template< Size> 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.
template< Size> 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.
template< Size> 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.
template< Size> 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.
template< Size> 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.
template< typename T, Size> 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.
template< typename T, Size> Vector < T , DIM > mi::math::pow( const Vector_struct < T , DIM >& a, T b)
Returns the vector a elementwise to the power of b.
template< typename T, Size> Vector < T , DIM > mi::math::radians( const Vector_struct < T , DIM >& v)
Converts elementwise degrees in v to radians.
template< typename T, Size> 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.
template< typename T, Size> Vector < T , DIM > mi::math::rsqrt( const Vector_struct < T , DIM >& v)
Returns the reciprocal of the square root of each element of v.
template< typename T, Size> Vector < T , DIM > mi::math::saturate( const Vector_struct < T , DIM >& v)
Returns the vector v clamped elementwise to the range [0,1].
template< typename T, Size> Vector < T , DIM > mi::math::sign( const Vector_struct < T , DIM >& v)
Returns the elementwise sign of vector v.
template< typename T, Size> Vector < T , DIM > mi::math::sin( const Vector_struct < T , DIM >& v)
Returns a vector with the elementwise sine of the vector v.
template< typename T, Size>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> 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> 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> Vector < T , DIM > mi::math::sqrt( const Vector_struct < T , DIM >& v)
Returns the square root of each element of v.
template< typename T, Size> 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.
template< typename T, Size> Vector < T , DIM > mi::math::tan( const Vector_struct < T , DIM >& v)
Returns a vector with the elementwise tangent of the vector v.

Functions

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

bool mi::math::all( const Vector_struct < T , DIM >& v) [inline]

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

template< typename T, Size>

bool mi::math::any( const Vector_struct < T , DIM >& v) [inline]

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

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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

template< typename T, Size>

Vector < T , DIM > mi::math::clamp( const Vector_struct < T , DIM >& v, const Vector_struct < T , DIM >& low, T high) [inline]

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

template< typename T, Size>

Vector < T , DIM > mi::math::clamp( const Vector_struct < T , DIM >& v, T low, const Vector_struct < T , DIM >& high) [inline]

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

template< typename T, Size>

Vector < T , DIM > mi::math::clamp( const Vector_struct < T , DIM >& v, T low, T high) [inline]

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

template< typename T2, Size, typename T1, Size>

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.

template< typename T, Size>

Vector < T , DIM > mi::math::cos( const Vector_struct < T , DIM >& v) [inline]

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

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.

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.

template< typename T, Size>

Vector < T , DIM > mi::math::degrees( const Vector_struct < T , DIM >& v) [inline]

Converts elementwise radians in v to degrees.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

Vector < T , DIM > mi::math::fmod( const Vector_struct < T , DIM >& a, T b) [inline]

Returns elementwise a modulo b, in other words, the remainder of a/b. The elementwise result has the same sign as a.

template< typename T, Size>

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.

template< typename T, Size>

bool mi::math::is_approx_equal( const Vector_struct < T , DIM >& left, const Vector_struct < T , DIM >& right, T e) [inline]

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

template< typename T, Size>

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

v1
one vector
v2
second vector
t
interpolation parameter in [0,1]

template< typename T, Size>

Vector < T , DIM > mi::math::lerp( const Vector_struct < T , DIM >& v1, const Vector_struct < T , DIM >& v2, T t) [inline]

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

Parameters

v1
one vector
v2
second vector
t
interpolation parameter in [0,1]

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

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

n
input, normal vector
u
output, first vector in tangent plane
v
output, second vector in tangent plane

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

n
input, normal vector
u
input, first direction vector
v
input, second direction vector
t
output, first vector in tangent plane
b
output, second vector in tangent plane

template< typename T, Size>

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.

template< Size>

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

Returns the elementwise logical not of a boolean vector.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, typename TT, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, typename TT, Size>

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.

template< Size>

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.

template< Size>

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.

template< Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, typename TT, Size>

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.

template< typename T, typename TT, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, typename TT, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

Vector < T , DIM >& mi::math::operator++( Vector < T , DIM >& vec) [inline]

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

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

Vector < T , DIM > mi::math::operator-( const Vector_struct < T , DIM >& v) [inline]

Negates the vector v elementwise and returns the new result.

template< typename T, Size>

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.

template< typename T, Size>

Vector < T , DIM > mi::math::operator-( const Vector < T , DIM >& v) [inline]

Negates the vector v elementwise and returns the new result.

template< typename T, Size>

Vector < T , DIM >& mi::math::operator--( Vector < T , DIM >& vec) [inline]

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

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, typename U, Size>

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.

template< typename T, typename U, Size>

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.

template< typename T, typename TT, Size>

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.

template< typename T, typename U, Size>

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.

template< typename T, typename U, Size>

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.

template< typename T, typename TT, Size>

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.

template< Size>

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.

template< Size>

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.

template< Size>

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.

template< Size>

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.

template< Size>

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.

template< Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

Vector < T , DIM > mi::math::pow( const Vector_struct < T , DIM >& a, T b) [inline]

Returns the vector a elementwise to the power of b.

template< typename T, Size>

Vector < T , DIM > mi::math::radians( const Vector_struct < T , DIM >& v) [inline]

Converts elementwise degrees in v to radians.

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

Vector < T , DIM > mi::math::saturate( const Vector_struct < T , DIM >& v) [inline]

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

template< typename T, Size>

Vector < T , DIM > mi::math::sign( const Vector_struct < T , DIM >& v) [inline]

Returns the elementwise sign of vector v.

template< typename T, Size>

Vector < T , DIM > mi::math::sin( const Vector_struct < T , DIM >& v) [inline]

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

template< typename T, Size>

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.

template< typename T, Size>

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.

template< typename T, Size>

Vector < T , DIM > mi::math::smoothstep( const Vector_struct < T , DIM >& a, const Vector_struct < T , DIM >& b, T 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.

template< typename T, Size>

Vector < T , DIM > mi::math::sqrt( const Vector_struct < T , DIM >& v) [inline]

Returns the square root of each element of v.

template< typename T, Size>

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.

template< typename T, Size>

Vector < T , DIM > mi::math::tan( const Vector_struct < T , DIM >& v) [inline]

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