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

#include <ImathVec.h>

+ Inheritance diagram for Vec3< T >:

Public Types

typedef T BaseType
 

Public Member Functions

IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 T
operator[] (int i) IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE constexpr
const T
operator[] (int i) const IMATH_NOEXCEPT
 
Constructors and Assignment
IMATH_HOSTDEVICE Vec3 () IMATH_NOEXCEPT
 Uninitialized by default. More...
 
IMATH_HOSTDEVICE constexpr Vec3 (T a) IMATH_NOEXCEPT
 Initialize to a scalar (a,a,a) More...
 
IMATH_HOSTDEVICE constexpr Vec3 (T a, T b, T c) IMATH_NOEXCEPT
 Initialize to given elements (a,b,c) More...
 
IMATH_HOSTDEVICE constexpr Vec3 (const Vec3 &v) IMATH_NOEXCEPT
 Copy constructor. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr Vec3 (const Vec3< S > &v) IMATH_NOEXCEPT
 Construct from Vec3 of another base type. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr Vec3 (const Vec4< S > &v) IMATH_NOEXCEPT
 
template<class S >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Vec3 (const Vec4< S > &v, InfException)
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator= (const Vec3 &v) IMATH_NOEXCEPT
 Assignment. More...
 
 ~Vec3 () IMATH_NOEXCEPT=default
 Destructor. More...
 
Interoperability with other vector types

Construction and assignment are allowed from other classes that appear to be equivalent vector types, provided that they have either a subscripting operator, or data members .x, .y, .z, that are of the same type as the elements of this vector, and their size appears to be the right number of elements.

This functionality is disabled for gcc 4.x, which seems to have a compiler bug that results in spurious errors. It can also be disabled by defining IMATH_FOREIGN_VECTOR_INTEROP to be 0 prior to including any Imath header files.

template<typename V , IMATH_ENABLE_IF(has_xyz< V, T >::value) >
IMATH_HOSTDEVICE constexpr Vec3 (const V &v) IMATH_NOEXCEPT
 
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 3 >::value &&!has_xyz< V, T >::value) >
IMATH_HOSTDEVICE Vec3 (const V &v)
 
template<typename V , IMATH_ENABLE_IF(has_xyz< V, T >::value) >
IMATH_HOSTDEVICE const Vec3operator= (const V &v) IMATH_NOEXCEPT
 
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 3 >::value &&!has_xyz< V, T >::value) >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator= (const V &v)
 
Compatibility with Sb
template<class S >
IMATH_HOSTDEVICE void setValue (S a, S b, S c) IMATH_NOEXCEPT
 Set the value. More...
 
template<class S >
IMATH_HOSTDEVICE void setValue (const Vec3< S > &v) IMATH_NOEXCEPT
 Set the value. More...
 
template<class S >
IMATH_HOSTDEVICE void getValue (S &a, S &b, S &c) const IMATH_NOEXCEPT
 Return the value in a, b, and c More...
 
template<class S >
IMATH_HOSTDEVICE void getValue (Vec3< S > &v) const IMATH_NOEXCEPT
 Return the value in v More...
 
IMATH_HOSTDEVICE TgetValue () IMATH_NOEXCEPT
 Return a raw pointer to the array of values. More...
 
IMATH_HOSTDEVICE const TgetValue () const IMATH_NOEXCEPT
 Return a raw pointer to the array of values. More...
 
Arithmetic and Comparison
template<class S >
IMATH_HOSTDEVICE constexpr bool operator== (const Vec3< S > &v) const IMATH_NOEXCEPT
 Equality. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr bool operator!= (const Vec3< S > &v) const IMATH_NOEXCEPT
 Inequality. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 bool 
equalWithAbsError (const Vec3< T > &v, T e) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 bool 
equalWithRelError (const Vec3< T > &v, T e) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE constexpr T dot (const Vec3 &v) const IMATH_NOEXCEPT
 Dot product. More...
 
IMATH_HOSTDEVICE constexpr T operator^ (const Vec3 &v) const IMATH_NOEXCEPT
 Dot product. More...
 
IMATH_HOSTDEVICE constexpr Vec3 cross (const Vec3 &v) const IMATH_NOEXCEPT
 Right-handed cross product. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator%= (const Vec3 &v) IMATH_NOEXCEPT
 Right-handed cross product. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator% (const Vec3 &v) const IMATH_NOEXCEPT
 Right-handed cross product. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator+= (const Vec3 &v) IMATH_NOEXCEPT
 Component-wise addition. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator+ (const Vec3 &v) const IMATH_NOEXCEPT
 Component-wise addition. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator-= (const Vec3 &v) IMATH_NOEXCEPT
 Component-wise subtraction. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator- (const Vec3 &v) const IMATH_NOEXCEPT
 Component-wise subtraction. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator- () const IMATH_NOEXCEPT
 Component-wise multiplication by -1. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
negate () IMATH_NOEXCEPT
 Component-wise multiplication by -1. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator*= (const Vec3 &v) IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator*= (T a) IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator* (const Vec3 &v) const IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator* (T a) const IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator/= (const Vec3 &v) IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator/= (T a) IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator/ (const Vec3 &v) const IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE constexpr Vec3 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 Vec3normalize () IMATH_NOEXCEPT
 Normalize in place. If length()==0, return a null vector. More...
 
const Vec3normalizeExc ()
 Normalize in place. If length()==0, throw an exception. More...
 
IMATH_HOSTDEVICE const Vec3normalizeNonNull () IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE Vec3< Tnormalized () const IMATH_NOEXCEPT
 Return a normalized vector. Does not modify *this. More...
 
Vec3< TnormalizedExc () const
 
IMATH_HOSTDEVICE Vec3< TnormalizedNonNull () const IMATH_NOEXCEPT
 

Static Public Member Functions

IMATH_HOSTDEVICE static
constexpr unsigned int 
dimensions () IMATH_NOEXCEPT
 Return the number of dimensions, i.e. 3. 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
 

Detailed Description

template<class T>
class Vec3< T >

3-element vector

Definition at line 40 of file ImathVec.h.

Member Typedef Documentation

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

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

Definition at line 685 of file ImathVec.h.

Constructor & Destructor Documentation

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

Uninitialized by default.

Definition at line 1705 of file ImathVec.h.

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

Initialize to a scalar (a,a,a)

Definition at line 1711 of file ImathVec.h.

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

Initialize to given elements (a,b,c)

Definition at line 1717 of file ImathVec.h.

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

Copy constructor.

Definition at line 1724 of file ImathVec.h.

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

Construct from Vec3 of another base type.

Definition at line 1732 of file ImathVec.h.

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

Vec4 to Vec3 conversion: divide x, y and z by w, even if w is 0. The result depends on how the environment handles floating-point exceptions.

Definition at line 1750 of file ImathVec.h.

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

Vec4 to Vec3 conversion: divide x, y and z by w. Throws an exception if w is zero or if division by w would overflow.

Definition at line 1759 of file ImathVec.h.

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

Destructor.

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

Interoperability assignment from another type that behaves as if it were an equivalent vector.

Definition at line 447 of file ImathVec.h.

template<class T>
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 3 >::value &&!has_xyz< V, T >::value) >
IMATH_HOSTDEVICE Vec3< T >::Vec3 ( const V &  v)
inlineexplicit

Interoperability assignment from another type that behaves as if it were an equivalent vector.

Definition at line 455 of file ImathVec.h.

Member Function Documentation

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

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

Definition at line 670 of file ImathVec.h.

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

Largest possible negative value.

Definition at line 652 of file ImathVec.h.

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

Largest possible positive value.

Definition at line 658 of file ImathVec.h.

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

Smallest possible positive value.

Definition at line 664 of file ImathVec.h.

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

Right-handed cross product.

Definition at line 1889 of file ImathVec.h.

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

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

Definition at line 678 of file ImathVec.h.

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

Dot product.

Definition at line 1875 of file ImathVec.h.

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

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

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

Definition at line 1853 of file ImathVec.h.

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

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

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

Definition at line 1864 of file ImathVec.h.

template<class T >
template<class S >
IMATH_HOSTDEVICE void Vec3< T >::getValue ( S a,
S b,
S c 
) const
inline

Return the value in a, b, and c

Definition at line 1804 of file ImathVec.h.

template<class T >
template<class S >
IMATH_HOSTDEVICE void Vec3< T >::getValue ( Vec3< S > &  v) const
inline

Return the value in v

Definition at line 1814 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE T * Vec3< T >::getValue ( )
inline

Return a raw pointer to the array of values.

Definition at line 1823 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE const T * Vec3< T >::getValue ( ) const
inline

Return a raw pointer to the array of values.

Definition at line 1830 of file ImathVec.h.

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

Return the Euclidean norm.

Definition at line 2064 of file ImathVec.h.

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

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

Definition at line 2076 of file ImathVec.h.

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

Component-wise multiplication by -1.

Definition at line 1957 of file ImathVec.h.

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

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

Definition at line 2083 of file ImathVec.h.

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

Return a normalized vector. Does not modify *this.

Definition at line 2131 of file ImathVec.h.

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

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

Definition at line 2142 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE Vec3< T > Vec3< 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 2154 of file ImathVec.h.

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

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

Definition at line 2105 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE const Vec3< T > & Vec3< 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 2120 of file ImathVec.h.

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

Inequality.

Definition at line 1846 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE constexpr Vec3< T > Vec3< T >::operator% ( const Vec3< T > &  v) const
inline

Right-handed cross product.

Definition at line 1909 of file ImathVec.h.

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

Right-handed cross product.

Definition at line 1896 of file ImathVec.h.

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

Component-wise multiplication.

Definition at line 1987 of file ImathVec.h.

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

Component-wise multiplication.

Definition at line 1994 of file ImathVec.h.

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

Component-wise multiplication.

Definition at line 1967 of file ImathVec.h.

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

Component-wise multiplication.

Definition at line 1977 of file ImathVec.h.

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

Component-wise addition.

Definition at line 1926 of file ImathVec.h.

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

Component-wise addition.

Definition at line 1916 of file ImathVec.h.

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

Component-wise subtraction.

Definition at line 1943 of file ImathVec.h.

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

Component-wise multiplication by -1.

Definition at line 1950 of file ImathVec.h.

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

Component-wise subtraction.

Definition at line 1933 of file ImathVec.h.

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

Component-wise division.

Definition at line 2021 of file ImathVec.h.

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

Component-wise division.

Definition at line 2028 of file ImathVec.h.

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

Component-wise division.

Definition at line 2001 of file ImathVec.h.

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

Component-wise division.

Definition at line 2011 of file ImathVec.h.

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

Assignment.

Definition at line 1740 of file ImathVec.h.

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

Interoperability assignment from another type that behaves as if it were an equivalent vector.

Definition at line 462 of file ImathVec.h.

template<class T>
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 3 >::value &&!has_xyz< V, T >::value) >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Vec3& Vec3< T >::operator= ( const V &  v)
inline

Interoperability assignment from another type that behaves as if it were an equivalent vector.

Definition at line 474 of file ImathVec.h.

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

Equality.

Definition at line 1838 of file ImathVec.h.

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

Element access by index.

NB: This method of access uses dynamic array accesses which can prevent compiler optimizations and force temporaries to be stored to the stack and other missed vectorization opportunities. Use of direct access to x, y, z when possible should be preferred.

Definition at line 1682 of file ImathVec.h.

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

Element access by index.

NB: This method of access uses dynamic array accesses which can prevent compiler optimizations and force temporaries to be stored to the stack and other missed vectorization opportunities. Use of direct access to x, y, z when possible should be preferred.

Definition at line 1689 of file ImathVec.h.

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

Dot product.

Definition at line 1882 of file ImathVec.h.

template<class T >
template<class S >
IMATH_HOSTDEVICE void Vec3< T >::setValue ( S  a,
S  b,
S  c 
)
inline

Set the value.

Definition at line 1784 of file ImathVec.h.

template<class T >
template<class S >
IMATH_HOSTDEVICE void Vec3< T >::setValue ( const Vec3< S > &  v)
inline

Set the value.

Definition at line 1794 of file ImathVec.h.

Member Data Documentation

template<class T>
T Vec3< T >::x

Definition at line 368 of file ImathVec.h.

template<class T>
T Vec3< T >::y

Definition at line 368 of file ImathVec.h.

template<class T>
T Vec3< T >::z

Definition at line 368 of file ImathVec.h.


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