HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vec2< 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 Vec2 () IMATH_NOEXCEPT
 Uninitialized by default. More...
 
IMATH_HOSTDEVICE constexpr Vec2 (T a) IMATH_NOEXCEPT
 Initialize to a scalar (a,a) More...
 
IMATH_HOSTDEVICE constexpr Vec2 (T a, T b) IMATH_NOEXCEPT
 Initialize to given elements (a,b) More...
 
IMATH_HOSTDEVICE constexpr Vec2 (const Vec2 &v) IMATH_NOEXCEPT
 Copy constructor. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr Vec2 (const Vec2< S > &v) IMATH_NOEXCEPT
 Construct from Vec2 of another base type. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec2
operator= (const Vec2 &v) IMATH_NOEXCEPT
 Assignment. More...
 
 ~Vec2 () 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 and .y, 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_xy< V, T >::value) >
IMATH_HOSTDEVICE constexpr Vec2 (const V &v) IMATH_NOEXCEPT
 
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 2 >::value &&!has_xy< V, T >::value) >
IMATH_HOSTDEVICE Vec2 (const V &v)
 
template<typename V , IMATH_ENABLE_IF(has_xy< V, T >::value) >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec2
operator= (const V &v) IMATH_NOEXCEPT
 
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 2 >::value &&!has_xy< V, T >::value) >
IMATH_HOSTDEVICE const Vec2operator= (const V &v)
 
Compatibility with Sb
template<class S >
IMATH_HOSTDEVICE void setValue (S a, S b) IMATH_NOEXCEPT
 Set the value. More...
 
template<class S >
IMATH_HOSTDEVICE void setValue (const Vec2< S > &v) IMATH_NOEXCEPT
 Set the value. More...
 
template<class S >
IMATH_HOSTDEVICE void getValue (S &a, S &b) const IMATH_NOEXCEPT
 Return the value in a and b More...
 
template<class S >
IMATH_HOSTDEVICE void getValue (Vec2< 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 Vec2< S > &v) const IMATH_NOEXCEPT
 Equality. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr bool operator!= (const Vec2< S > &v) const IMATH_NOEXCEPT
 Inequality. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 bool 
equalWithAbsError (const Vec2< T > &v, T e) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 bool 
equalWithRelError (const Vec2< T > &v, T e) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE constexpr T dot (const Vec2 &v) const IMATH_NOEXCEPT
 Dot product. More...
 
IMATH_HOSTDEVICE constexpr T operator^ (const Vec2 &v) const IMATH_NOEXCEPT
 Dot product. More...
 
IMATH_HOSTDEVICE constexpr T cross (const Vec2 &v) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE constexpr T operator% (const Vec2 &v) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec2
operator+= (const Vec2 &v) IMATH_NOEXCEPT
 Component-wise addition. More...
 
IMATH_HOSTDEVICE constexpr Vec2 operator+ (const Vec2 &v) const IMATH_NOEXCEPT
 Component-wise addition. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec2
operator-= (const Vec2 &v) IMATH_NOEXCEPT
 Component-wise subtraction. More...
 
IMATH_HOSTDEVICE constexpr Vec2 operator- (const Vec2 &v) const IMATH_NOEXCEPT
 Component-wise subtraction. More...
 
IMATH_HOSTDEVICE constexpr Vec2 operator- () const IMATH_NOEXCEPT
 Component-wise multiplication by -1. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec2
negate () IMATH_NOEXCEPT
 Component-wise multiplication by -1. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec2
operator*= (const Vec2 &v) IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec2
operator*= (T a) IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE constexpr Vec2 operator* (const Vec2 &v) const IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE constexpr Vec2 operator* (T a) const IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec2
operator/= (const Vec2 &v) IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec2
operator/= (T a) IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE constexpr Vec2 operator/ (const Vec2 &v) const IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE constexpr Vec2 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 Vec2normalize () IMATH_NOEXCEPT
 Normalize in place. If length()==0, return a null vector. More...
 
const Vec2normalizeExc ()
 Normalize in place. If length()==0, throw an exception. More...
 
IMATH_HOSTDEVICE const Vec2normalizeNonNull () IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE Vec2< Tnormalized () const IMATH_NOEXCEPT
 Return a normalized vector. Does not modify *this. More...
 
Vec2< TnormalizedExc () const
 
IMATH_HOSTDEVICE Vec2< TnormalizedNonNull () const IMATH_NOEXCEPT
 

Static Public Member Functions

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

Detailed Description

template<class T>
class Vec2< T >

2-element vector

Definition at line 31 of file ImathVec.h.

Member Typedef Documentation

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

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

Definition at line 292 of file ImathVec.h.

Constructor & Destructor Documentation

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

Uninitialized by default.

Definition at line 978 of file ImathVec.h.

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

Initialize to a scalar (a,a)

Definition at line 983 of file ImathVec.h.

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

Initialize to given elements (a,b)

Definition at line 988 of file ImathVec.h.

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

Copy constructor.

Definition at line 993 of file ImathVec.h.

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

Construct from Vec2 of another base type.

Definition at line 998 of file ImathVec.h.

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

Destructor.

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

Definition at line 106 of file ImathVec.h.

template<class T>
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 2 >::value &&!has_xy< V, T >::value) >
IMATH_HOSTDEVICE Vec2< T >::Vec2 ( const V &  v)
inlineexplicit

Definition at line 111 of file ImathVec.h.

Member Function Documentation

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

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

Definition at line 283 of file ImathVec.h.

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

Largest possible negative value.

Definition at line 274 of file ImathVec.h.

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

Largest possible positive value.

Definition at line 277 of file ImathVec.h.

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

Smallest possible positive value.

Definition at line 280 of file ImathVec.h.

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

Right-handed cross product, i.e. z component of Vec3 (this->x, this->y, 0) % Vec3 (v.x, v.y, 0)

Definition at line 1116 of file ImathVec.h.

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

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

Definition at line 288 of file ImathVec.h.

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

Dot product.

Definition at line 1102 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool Vec2< T >::equalWithAbsError ( const Vec2< 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 1080 of file ImathVec.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool Vec2< T >::equalWithRelError ( const Vec2< 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 1091 of file ImathVec.h.

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

Return the value in a and b

Definition at line 1033 of file ImathVec.h.

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

Return the value in v

Definition at line 1042 of file ImathVec.h.

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

Return a raw pointer to the array of values.

Definition at line 1050 of file ImathVec.h.

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

Return a raw pointer to the array of values.

Definition at line 1057 of file ImathVec.h.

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

Return the Euclidean norm.

Definition at line 1269 of file ImathVec.h.

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

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

Definition at line 1281 of file ImathVec.h.

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

Component-wise multiplication by -1.

Definition at line 1169 of file ImathVec.h.

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

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

Definition at line 1288 of file ImathVec.h.

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

Return a normalized vector. Does not modify *this.

Definition at line 1333 of file ImathVec.h.

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

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

Definition at line 1345 of file ImathVec.h.

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

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

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

Definition at line 1309 of file ImathVec.h.

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

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

Inequality.

Definition at line 1073 of file ImathVec.h.

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

Right-handed cross product, i.e. z component of Vec3 (this->x, this->y, 0) % Vec3 (v.x, v.y, 0)

Definition at line 1123 of file ImathVec.h.

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

Component-wise multiplication.

Definition at line 1196 of file ImathVec.h.

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

Component-wise multiplication.

Definition at line 1203 of file ImathVec.h.

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

Component-wise multiplication.

Definition at line 1178 of file ImathVec.h.

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

Component-wise multiplication.

Definition at line 1187 of file ImathVec.h.

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

Component-wise addition.

Definition at line 1139 of file ImathVec.h.

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

Component-wise addition.

Definition at line 1130 of file ImathVec.h.

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

Component-wise subtraction.

Definition at line 1155 of file ImathVec.h.

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

Component-wise multiplication by -1.

Definition at line 1162 of file ImathVec.h.

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

Component-wise subtraction.

Definition at line 1146 of file ImathVec.h.

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

Component-wise division.

Definition at line 1228 of file ImathVec.h.

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

Component-wise division.

Definition at line 1235 of file ImathVec.h.

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

Component-wise division.

Definition at line 1210 of file ImathVec.h.

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

Component-wise division.

Definition at line 1219 of file ImathVec.h.

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

Assignment.

Definition at line 1005 of file ImathVec.h.

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

Definition at line 114 of file ImathVec.h.

template<class T>
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 2 >::value &&!has_xy< V, T >::value) >
IMATH_HOSTDEVICE const Vec2& Vec2< T >::operator= ( const V &  v)
inline

Definition at line 122 of file ImathVec.h.

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

Equality.

Definition at line 1065 of file ImathVec.h.

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

Element access by index.

Definition at line 966 of file ImathVec.h.

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

Element access by index.

Definition at line 973 of file ImathVec.h.

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

Dot product.

Definition at line 1109 of file ImathVec.h.

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

Set the value.

Definition at line 1015 of file ImathVec.h.

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

Set the value.

Definition at line 1024 of file ImathVec.h.

Member Data Documentation

template<class T>
T Vec2< T >::x

Definition at line 52 of file ImathVec.h.

template<class T>
T Vec2< T >::y

Definition at line 52 of file ImathVec.h.


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