HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vec4< T > Class Template Reference

#include <ImathVec.h>

Public Types

typedef T BaseType
 

Public Member Functions

IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 T
operator[] (int i) IMATH_NOEXCEPT
 Element access by index. More...
 
IMATH_HOSTDEVICE constexpr
const T
operator[] (int i) const IMATH_NOEXCEPT
 Element access by index. More...
 
Constructors and Assignment
IMATH_HOSTDEVICE Vec4 () IMATH_NOEXCEPT
 Uninitialized by default. More...
 
IMATH_HOSTDEVICE constexpr Vec4 (T a) IMATH_NOEXCEPT
 Initialize to a scalar (a,a,a,a) More...
 
IMATH_HOSTDEVICE constexpr Vec4 (T a, T b, T c, T d) IMATH_NOEXCEPT
 Initialize to given elements (a,b,c,d) More...
 
IMATH_HOSTDEVICE constexpr Vec4 (const Vec4 &v) IMATH_NOEXCEPT
 Copy constructor. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr Vec4 (const Vec4< S > &v) IMATH_NOEXCEPT
 Construct from Vec4 of another base type. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr Vec4 (const Vec3< S > &v) IMATH_NOEXCEPT
 Vec3 to Vec4 conversion, sets w to 1. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec4
operator= (const Vec4 &v) IMATH_NOEXCEPT
 Assignment. More...
 
 ~Vec4 () IMATH_NOEXCEPT=default
 Destructor. More...
 
Interoperability with other vector types
template<typename V , IMATH_ENABLE_IF(has_xyzw< V, T >::value) >
IMATH_HOSTDEVICE constexpr Vec4 (const V &v) IMATH_NOEXCEPT
 
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 4 >::value &&!has_xyzw< V, T >::value) >
IMATH_HOSTDEVICE Vec4 (const V &v)
 
template<typename V , IMATH_ENABLE_IF(has_xyzw< V, T >::value) >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec4
operator= (const V &v) IMATH_NOEXCEPT
 
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 4 >::value &&!has_xyzw< V, T >::value) >
IMATH_HOSTDEVICE const Vec4operator= (const V &v)
 
Arithmetic and Comparison
template<class S >
IMATH_HOSTDEVICE constexpr bool operator== (const Vec4< S > &v) const IMATH_NOEXCEPT
 Equality. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr bool operator!= (const Vec4< S > &v) const IMATH_NOEXCEPT
 Inequality. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 bool 
equalWithAbsError (const Vec4< T > &v, T e) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 bool 
equalWithRelError (const Vec4< T > &v, T e) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE constexpr T dot (const Vec4 &v) const IMATH_NOEXCEPT
 Dot product. More...
 
IMATH_HOSTDEVICE constexpr T operator^ (const Vec4 &v) const IMATH_NOEXCEPT
 Dot product. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec4
operator+= (const Vec4 &v) IMATH_NOEXCEPT
 Component-wise addition. More...
 
IMATH_HOSTDEVICE constexpr Vec4 operator+ (const Vec4 &v) const IMATH_NOEXCEPT
 Component-wise addition. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec4
operator-= (const Vec4 &v) IMATH_NOEXCEPT
 Component-wise subtraction. More...
 
IMATH_HOSTDEVICE constexpr Vec4 operator- (const Vec4 &v) const IMATH_NOEXCEPT
 Component-wise subtraction. More...
 
IMATH_HOSTDEVICE constexpr Vec4 operator- () const IMATH_NOEXCEPT
 Component-wise multiplication by -1. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec4
negate () IMATH_NOEXCEPT
 Component-wise multiplication by -1. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec4
operator*= (const Vec4 &v) IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec4
operator*= (T a) IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE constexpr Vec4 operator* (const Vec4 &v) const IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE constexpr Vec4 operator* (T a) const IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec4
operator/= (const Vec4 &v) IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec4
operator/= (T a) IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE constexpr Vec4 operator/ (const Vec4 &v) const IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE constexpr Vec4 operator/ (T a) const IMATH_NOEXCEPT
 Component-wise division. More...
 
Query and Manipulation
IMATH_HOSTDEVICE T length () const IMATH_NOEXCEPT
 Return the Euclidean norm. More...
 
IMATH_HOSTDEVICE constexpr T length2 () const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE const Vec4normalize () IMATH_NOEXCEPT
 Normalize in place. If length()==0, return a null vector. More...
 
const Vec4normalizeExc ()
 Normalize in place. If length()==0, throw an exception. More...
 
IMATH_HOSTDEVICE const Vec4normalizeNonNull () IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE Vec4< Tnormalized () const IMATH_NOEXCEPT
 Return a normalized vector. Does not modify *this. More...
 
Vec4< TnormalizedExc () const
 
IMATH_HOSTDEVICE Vec4< TnormalizedNonNull () const IMATH_NOEXCEPT
 

Static Public Member Functions

IMATH_HOSTDEVICE static
constexpr unsigned int 
dimensions () IMATH_NOEXCEPT
 Return the number of dimensions, i.e. 4. More...
 
Numeric Limits
IMATH_HOSTDEVICE static constexpr T baseTypeLowest () IMATH_NOEXCEPT
 Largest possible negative value. More...
 
IMATH_HOSTDEVICE static constexpr T baseTypeMax () IMATH_NOEXCEPT
 Largest possible positive value. More...
 
IMATH_HOSTDEVICE static constexpr T baseTypeSmallest () IMATH_NOEXCEPT
 Smallest possible positive value. More...
 
IMATH_HOSTDEVICE static constexpr T baseTypeEpsilon () IMATH_NOEXCEPT
 Smallest possible e for which 1+e != 1. More...
 

Public Attributes

Direct access to elements
T x
 
T y
 
T z
 
T w
 

Detailed Description

template<class T>
class Vec4< T >

4-element vector

Definition at line 33 of file ImathVec.h.

Member Typedef Documentation

template<class T>
typedef T Vec4< T >::BaseType

The base type: In templates that accept a parameter V, you can refer to T as V::BaseType

Definition at line 796 of file ImathVec.h.

Constructor & Destructor Documentation

template<class T >
IMATH_HOSTDEVICE Vec4< T >::Vec4 ( )
inline

Uninitialized by default.

Definition at line 1850 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec4< T >::Vec4 ( T  a)
inlineexplicit

Initialize to a scalar (a,a,a,a)

Definition at line 1855 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec4< T >::Vec4 ( T  a,
T  b,
T  c,
T  d 
)
inline

Initialize to given elements (a,b,c,d)

Definition at line 1860 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec4< T >::Vec4 ( const Vec4< T > &  v)
inline

Copy constructor.

Definition at line 1865 of file ImathVec.h.

template<class T >
template<class S >
IMATH_HOSTDEVICE constexpr Vec4< T >::Vec4 ( const Vec4< S > &  v)
inline

Construct from Vec4 of another base type.

Definition at line 1871 of file ImathVec.h.

template<class T >
template<class S >
IMATH_HOSTDEVICE constexpr Vec4< T >::Vec4 ( const Vec3< S > &  v)
inlineexplicit

Vec3 to Vec4 conversion, sets w to 1.

Definition at line 1888 of file ImathVec.h.

template<class T>
Vec4< T >::~Vec4 ( )
default

Destructor.

template<class T>
template<typename V , IMATH_ENABLE_IF(has_xyzw< V, T >::value) >
IMATH_HOSTDEVICE constexpr Vec4< T >::Vec4 ( const V &  v)
inlineexplicit

Definition at line 637 of file ImathVec.h.

template<class T>
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 4 >::value &&!has_xyzw< V, T >::value) >
IMATH_HOSTDEVICE Vec4< T >::Vec4 ( const V &  v)
inlineexplicit

Definition at line 642 of file ImathVec.h.

Member Function Documentation

template<class T>
IMATH_HOSTDEVICE static constexpr T Vec4< T >::baseTypeEpsilon ( )
inlinestatic

Smallest possible e for which 1+e != 1.

Definition at line 787 of file ImathVec.h.

template<class T>
IMATH_HOSTDEVICE static constexpr T Vec4< T >::baseTypeLowest ( )
inlinestatic

Largest possible negative value.

Definition at line 778 of file ImathVec.h.

template<class T>
IMATH_HOSTDEVICE static constexpr T Vec4< T >::baseTypeMax ( )
inlinestatic

Largest possible positive value.

Definition at line 781 of file ImathVec.h.

template<class T>
IMATH_HOSTDEVICE static constexpr T Vec4< T >::baseTypeSmallest ( )
inlinestatic

Smallest possible positive value.

Definition at line 784 of file ImathVec.h.

template<class T>
IMATH_HOSTDEVICE static constexpr unsigned int Vec4< T >::dimensions ( )
inlinestatic

Return the number of dimensions, i.e. 4.

Definition at line 792 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr T Vec4< T >::dot ( const Vec4< T > &  v) const
inline

Dot product.

Definition at line 1933 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool Vec4< T >::equalWithAbsError ( const Vec4< T > &  v,
T  e 
) const
inline

Compare two matrices and test if they are "approximately equal":

Returns
True if the coefficients of this and m are the same with an absolute error of no more than e, i.e., for all i, j:
abs (this[i][j] - m[i][j]) <= e  

Definition at line 1911 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool Vec4< T >::equalWithRelError ( const Vec4< T > &  v,
T  e 
) const
inline

Compare two matrices and test if they are "approximately equal":

Returns
True if the coefficients of this and m are the same with a relative error of no more than e, i.e., for all i, j:
abs (this[i] - v[i][j]) <= e * abs (this[i][j])  

Definition at line 1922 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE T Vec4< T >::length ( void  ) const
inline

Return the Euclidean norm.

Definition at line 2110 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr T Vec4< T >::length2 ( ) const
inline

Return the square of the Euclidean norm, i.e. the dot product with itself.

Definition at line 2122 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Vec4< T > & Vec4< T >::negate ( )
inline

Component-wise multiplication by -1.

Definition at line 1990 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE const Vec4< T > & Vec4< T >::normalize ( )
inline

Normalize in place. If length()==0, return a null vector.

Definition at line 2129 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE Vec4< T > Vec4< T >::normalized ( ) const
inline

Return a normalized vector. Does not modify *this.

Definition at line 2180 of file ImathVec.h.

template<class T >
Vec4< T > Vec4< T >::normalizedExc ( ) const
inline

Return a normalized vector. Does not modify *this. Throw an exception if length()==0.

Definition at line 2192 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE Vec4< T > Vec4< T >::normalizedNonNull ( ) const
inline

Return a normalized vector. Does not modify *this, and does not check for length()==0. Slightly faster than the other normalization routines, but if v.length() is 0.0, the result is undefined.

Definition at line 2204 of file ImathVec.h.

template<class T >
const Vec4< T > & Vec4< T >::normalizeExc ( )
inline

Normalize in place. If length()==0, throw an exception.

Definition at line 2152 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE const Vec4< T > & Vec4< T >::normalizeNonNull ( )
inline

Normalize without any checks for length()==0. Slightly faster than the other normalization routines, but if v.length() is 0.0, the result is undefined.

Definition at line 2168 of file ImathVec.h.

template<class T >
template<class S >
IMATH_HOSTDEVICE constexpr bool Vec4< T >::operator!= ( const Vec4< S > &  v) const
inline

Inequality.

Definition at line 1904 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec4< T > Vec4< T >::operator* ( const Vec4< T > &  v) const
inline

Component-wise multiplication.

Definition at line 2023 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec4< T > Vec4< T >::operator* ( T  a) const
inline

Component-wise multiplication.

Definition at line 2030 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Vec4< T > & Vec4< T >::operator*= ( const Vec4< T > &  v)
inline

Component-wise multiplication.

Definition at line 2001 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Vec4< T > & Vec4< T >::operator*= ( T  a)
inline

Component-wise multiplication.

Definition at line 2012 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec4< T > Vec4< T >::operator+ ( const Vec4< T > &  v) const
inline

Component-wise addition.

Definition at line 1958 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Vec4< T > & Vec4< T >::operator+= ( const Vec4< T > &  v)
inline

Component-wise addition.

Definition at line 1947 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec4< T > Vec4< T >::operator- ( const Vec4< T > &  v) const
inline

Component-wise subtraction.

Definition at line 1976 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec4< T > Vec4< T >::operator- ( ) const
inline

Component-wise multiplication by -1.

Definition at line 1983 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Vec4< T > & Vec4< T >::operator-= ( const Vec4< T > &  v)
inline

Component-wise subtraction.

Definition at line 1965 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec4< T > Vec4< T >::operator/ ( const Vec4< T > &  v) const
inline

Component-wise division.

Definition at line 2059 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec4< T > Vec4< T >::operator/ ( T  a) const
inline

Component-wise division.

Definition at line 2066 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Vec4< T > & Vec4< T >::operator/= ( const Vec4< T > &  v)
inline

Component-wise division.

Definition at line 2037 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Vec4< T > & Vec4< T >::operator/= ( T  a)
inline

Component-wise division.

Definition at line 2048 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Vec4< T > & Vec4< T >::operator= ( const Vec4< T > &  v)
inline

Assignment.

Definition at line 1878 of file ImathVec.h.

template<class T>
template<typename V , IMATH_ENABLE_IF(has_xyzw< V, T >::value) >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Vec4& Vec4< T >::operator= ( const V &  v)
inline

Definition at line 645 of file ImathVec.h.

template<class T>
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 4 >::value &&!has_xyzw< V, T >::value) >
IMATH_HOSTDEVICE const Vec4& Vec4< T >::operator= ( const V &  v)
inline

Definition at line 655 of file ImathVec.h.

template<class T >
template<class S >
IMATH_HOSTDEVICE constexpr bool Vec4< T >::operator== ( const Vec4< S > &  v) const
inline

Equality.

Definition at line 1896 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T & Vec4< T >::operator[] ( int  i)
inline

Element access by index.

Definition at line 1838 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr const T & Vec4< T >::operator[] ( int  i) const
inline

Element access by index.

Definition at line 1845 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr T Vec4< T >::operator^ ( const Vec4< T > &  v) const
inline

Dot product.

Definition at line 1940 of file ImathVec.h.

Member Data Documentation

template<class T>
T Vec4< T >::w

Definition at line 581 of file ImathVec.h.

template<class T>
T Vec4< T >::x

Definition at line 581 of file ImathVec.h.

template<class T>
T Vec4< T >::y

Definition at line 581 of file ImathVec.h.

template<class T>
T Vec4< T >::z

Definition at line 581 of file ImathVec.h.


The documentation for this class was generated from the following file: