UT_Vector4T< T > Class Template Reference

4D Vector class. More...

#include <UT_Vector4.h>

List of all members.

Public Member Functions

 UT_Vector4T (void)
 UT_Vector4T (T vx, T vy, T vz, T vw=1.0f)
 UT_Vector4T (const fpreal32 v[4])
 UT_Vector4T (const fpreal64 v[4])
 UT_Vector4T (const UT_Vector3T< T > &v, T w=1.f)
template<typename S >
 UT_Vector4T (const UT_Vector4T< S > &v)
template<typename S >
UT_Vector4T< T > & operator= (const UT_Vector4T< S > &v)
UT_Vector4T< T > & operator= (const UT_Vector3T< T > &v)
UT_Vector4T< T > & operator+= (const UT_Vector4T< T > &v)
UT_Vector4T< T > & operator-= (const UT_Vector4T< T > &v)
unsigned operator== (const UT_Vector4T< T > &v) const
unsigned operator!= (const UT_Vector4T< T > &v) const
int equalZero (T tol=0.00001f) const
int equalZero3 (T tol=0.00001f) const
void clampZero (T tol=0.00001f)
void clampZero3 (T tol=0.00001f)
void negate3 ()
void negate ()
void multiplyComponents (const UT_Vector4T< T > &v)
int isEqual (const UT_Vector4T< T > &v, T tol=0.00001f) const
int isEqual (const UT_Vector3T< T > &vect, T tol=0.00001f) const
bool isNan () const
UT_Vector4T< T > & operator= (T scalar)
UT_Vector4T< T > & operator+= (T scalar)
UT_Vector4T< T > & operator-= (T scalar)
UT_Vector4T< T > & operator*= (T scalar)
UT_Vector4T< T > & operator*= (const UT_Vector4T< T > &v)
UT_Vector4T< T > & operator/= (T scalar)
UT_Vector4T< T > & operator/= (const UT_Vector4T< T > &v)
maxComponent () const
minComponent () const
avgComponent () const
dot (const UT_Vector4T< T > &v) const
void normalize (void)
length (void) const
 The vector length (not to be confused with the vector dimension).
length2 (void) const
 The vector length squared.
unsigned hash () const
 Compute a hash.
void assign (T xx=0.0f, T yy=0.0f, T zz=0.0f, T ww=1.0f)
 Set the values of the vector components.
void assign (const T *v, int size=4)
 Set the values of the vector components.
void save (ostream &os, int binary=0) const
bool load (UT_IStream &is)
template<typename S >
void rowVecMult (const UT_Matrix4T< S > &m)
template<typename S >
void colVecMult (const UT_Matrix4T< S > &m)
template<typename S >
void rowVecMult3 (const UT_Matrix4T< S > &m)
template<typename S >
UT_Vector4T< T > & operator*= (const UT_Matrix4T< S > &mat)
template<typename S >
void multiply3 (const UT_Matrix4T< S > &mat)
template<typename S >
void multiply3 (UT_Vector4T< T > &dest, const UT_Matrix4T< S > &mat) const
int findMinAbsAxis () const
 These allow you to find out what indices to use for different axes.
int findMaxAbsAxis () const
 These allow you to find out what indices to use for different axes.
const T * data (void) const
T * data (void)
T & x (void)
x (void) const
T & y (void)
y (void) const
T & z (void)
z (void) const
T & w (void)
w (void) const
T & operator() (unsigned i)
operator() (unsigned i) const
T & operator[] (unsigned i)
operator[] (unsigned i) const
std::vector< T > asStdVector () const
void homogenize (void)
 Express the point in homogeneous coordinates or vice-versa.
void dehomogenize (void)
 Express the point in homogeneous coordinates or vice-versa.
bool save (UT_JSONWriter &w) const
bool save (UT_JSONValue &v) const
bool load (UT_JSONParser &p)

Static Public Member Functions

static int entries ()
 Returns the vector size.

Friends

ostream & operator<< (ostream &os, const UT_Vector4T< T > &v)
 I/O friends.


Detailed Description

template<typename T>
class UT_Vector4T< T >

4D Vector class.

Definition at line 141 of file UT_Vector4.h.


Constructor & Destructor Documentation

template<typename T>
UT_Vector4T< T >::UT_Vector4T ( void   )  [inline]

Default constructor. No data is initialized! Use it for extra speed.

Definition at line 145 of file UT_Vector4.h.

template<typename T>
UT_Vector4T< T >::UT_Vector4T ( vx,
vy,
vz,
vw = 1.0f 
) [inline]

Definition at line 148 of file UT_Vector4.h.

template<typename T>
UT_Vector4T< T >::UT_Vector4T ( const fpreal32  v[4]  )  [inline]

Definition at line 152 of file UT_Vector4.h.

template<typename T>
UT_Vector4T< T >::UT_Vector4T ( const fpreal64  v[4]  )  [inline]

Definition at line 156 of file UT_Vector4.h.

template<typename T>
UT_Vector4T< T >::UT_Vector4T ( const UT_Vector3T< T > &  v,
w = 1.f 
) [inline, explicit]

Definition at line 558 of file UT_Vector4.h.

template<typename T>
template<typename S >
UT_Vector4T< T >::UT_Vector4T ( const UT_Vector4T< S > &  v  )  [inline]

Definition at line 164 of file UT_Vector4.h.


Member Function Documentation

template<typename T>
void UT_Vector4T< T >::assign ( const T *  v,
int  size = 4 
) [inline]

Set the values of the vector components.

Definition at line 499 of file UT_Vector4.h.

template<typename T>
void UT_Vector4T< T >::assign ( xx = 0.0f,
yy = 0.0f,
zz = 0.0f,
ww = 1.0f 
) [inline]

Set the values of the vector components.

Definition at line 493 of file UT_Vector4.h.

template<typename T>
std::vector<T> UT_Vector4T< T >::asStdVector (  )  const

Return the components of the vector. The () operator does NOT check for the boundary condition.

template<typename T>
T UT_Vector4T< T >::avgComponent (  )  const [inline]

Definition at line 370 of file UT_Vector4.h.

template<typename T>
void UT_Vector4T< T >::clampZero ( tol = 0.00001f  )  [inline]

Definition at line 227 of file UT_Vector4.h.

template<typename T>
void UT_Vector4T< T >::clampZero3 ( tol = 0.00001f  )  [inline]

Definition at line 235 of file UT_Vector4.h.

template<typename T>
template<typename S >
void UT_Vector4T< T >::colVecMult ( const UT_Matrix4T< S > &  m  )  [inline]

If you need a multiplication operator that left multiplies the vector by a matrix (M * v), use the following colVecMult() functions. If you'd rather not use operator*=() for right-multiplications (v * M), use the following rowVecMult() functions.

Definition at line 276 of file UT_Vector4.h.

template<typename T>
T* UT_Vector4T< T >::data ( void   )  [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 455 of file UT_Vector4.h.

template<typename T>
const T* UT_Vector4T< T >::data ( void   )  const [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 454 of file UT_Vector4.h.

template<typename T>
void UT_Vector4T< T >::dehomogenize ( void   )  [inline]

Express the point in homogeneous coordinates or vice-versa.

Definition at line 515 of file UT_Vector4.h.

template<typename T>
T UT_Vector4T< T >::dot ( const UT_Vector4T< T > &  v  )  const [inline]

Definition at line 430 of file UT_Vector4.h.

template<typename T>
static int UT_Vector4T< T >::entries ( void   )  [inline, static]

Returns the vector size.

Definition at line 539 of file UT_Vector4.h.

template<typename T>
int UT_Vector4T< T >::equalZero ( tol = 0.00001f  )  const [inline]

Definition at line 213 of file UT_Vector4.h.

template<typename T>
int UT_Vector4T< T >::equalZero3 ( tol = 0.00001f  )  const [inline]

Definition at line 220 of file UT_Vector4.h.

template<typename T>
int UT_Vector4T< T >::findMaxAbsAxis (  )  const [inline]

These allow you to find out what indices to use for different axes.

Definition at line 402 of file UT_Vector4.h.

template<typename T>
int UT_Vector4T< T >::findMinAbsAxis (  )  const [inline]

These allow you to find out what indices to use for different axes.

Definition at line 377 of file UT_Vector4.h.

template<typename T>
unsigned UT_Vector4T< T >::hash (  )  const [inline]

Compute a hash.

Definition at line 488 of file UT_Vector4.h.

template<typename T>
void UT_Vector4T< T >::homogenize ( void   )  [inline]

Express the point in homogeneous coordinates or vice-versa.

Definition at line 509 of file UT_Vector4.h.

template<typename T>
int UT_Vector4T< T >::isEqual ( const UT_Vector3T< T > &  vect,
tol = 0.00001f 
) const [inline]

Definition at line 568 of file UT_Vector4.h.

template<typename T>
int UT_Vector4T< T >::isEqual ( const UT_Vector4T< T > &  v,
tol = 0.00001f 
) const [inline]

Definition at line 255 of file UT_Vector4.h.

template<typename T>
bool UT_Vector4T< T >::isNan (  )  const [inline]

Definition at line 264 of file UT_Vector4.h.

template<typename T>
T UT_Vector4T< T >::length ( void   )  const [inline]

The vector length (not to be confused with the vector dimension).

Definition at line 444 of file UT_Vector4.h.

template<typename T>
T UT_Vector4T< T >::length2 ( void   )  const [inline]

The vector length squared.

Definition at line 448 of file UT_Vector4.h.

template<typename T>
bool UT_Vector4T< T >::load ( UT_JSONParser p  ) 

Methods to serialize to a JSON stream. The vector is stored as an array of 4 reals.

template<typename T>
bool UT_Vector4T< T >::load ( UT_IStream is  ) 

template<typename T>
T UT_Vector4T< T >::maxComponent (  )  const [inline]

Definition at line 354 of file UT_Vector4.h.

template<typename T>
T UT_Vector4T< T >::minComponent (  )  const [inline]

Definition at line 362 of file UT_Vector4.h.

template<typename T>
template<typename S >
void UT_Vector4T< T >::multiply3 ( UT_Vector4T< T > &  dest,
const UT_Matrix4T< S > &  mat 
) const [inline]

Definition at line 304 of file UT_Vector4.h.

template<typename T>
template<typename S >
void UT_Vector4T< T >::multiply3 ( const UT_Matrix4T< S > &  mat  )  [inline]

Definition at line 301 of file UT_Vector4.h.

template<typename T>
void UT_Vector4T< T >::multiplyComponents ( const UT_Vector4T< T > &  v  )  [inline]

Definition at line 247 of file UT_Vector4.h.

template<typename T>
void UT_Vector4T< T >::negate ( void   )  [inline]

Definition at line 244 of file UT_Vector4.h.

template<typename T>
void UT_Vector4T< T >::negate3 (  )  [inline]

Definition at line 242 of file UT_Vector4.h.

template<typename T>
void UT_Vector4T< T >::normalize ( void   )  [inline]

Definition at line 434 of file UT_Vector4.h.

template<typename T>
unsigned UT_Vector4T< T >::operator!= ( const UT_Vector4T< T > &  v  )  const [inline]

Definition at line 211 of file UT_Vector4.h.

template<typename T>
T UT_Vector4T< T >::operator() ( unsigned  i  )  const [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 469 of file UT_Vector4.h.

template<typename T>
T& UT_Vector4T< T >::operator() ( unsigned  i  )  [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 464 of file UT_Vector4.h.

template<typename T>
UT_Vector4T<T>& UT_Vector4T< T >::operator*= ( const UT_Vector4T< T > &  v  )  [inline]

Definition at line 331 of file UT_Vector4.h.

template<typename T>
UT_Vector4T<T>& UT_Vector4T< T >::operator*= ( scalar  )  [inline]

Definition at line 324 of file UT_Vector4.h.

template<typename T>
template<typename S >
UT_Vector4T<T>& UT_Vector4T< T >::operator*= ( const UT_Matrix4T< S > &  mat  )  [inline]

Definition at line 297 of file UT_Vector4.h.

template<typename T>
UT_Vector4T<T>& UT_Vector4T< T >::operator+= ( scalar  )  [inline]

Definition at line 313 of file UT_Vector4.h.

template<typename T>
UT_Vector4T<T>& UT_Vector4T< T >::operator+= ( const UT_Vector4T< T > &  v  )  [inline]

Definition at line 188 of file UT_Vector4.h.

template<typename T>
UT_Vector4T<T>& UT_Vector4T< T >::operator-= ( scalar  )  [inline]

Definition at line 319 of file UT_Vector4.h.

template<typename T>
UT_Vector4T<T>& UT_Vector4T< T >::operator-= ( const UT_Vector4T< T > &  v  )  [inline]

Definition at line 197 of file UT_Vector4.h.

template<typename T>
UT_Vector4T<T>& UT_Vector4T< T >::operator/= ( const UT_Vector4T< T > &  v  )  [inline]

Definition at line 345 of file UT_Vector4.h.

template<typename T>
UT_Vector4T<T>& UT_Vector4T< T >::operator/= ( scalar  )  [inline]

Definition at line 340 of file UT_Vector4.h.

template<typename T>
UT_Vector4T<T>& UT_Vector4T< T >::operator= ( scalar  )  [inline]

Definition at line 308 of file UT_Vector4.h.

template<typename T>
UT_Vector4T<T>& UT_Vector4T< T >::operator= ( const UT_Vector3T< T > &  v  ) 

Assignment operator that creates a V4 from a V3 by adding a '1' element.

template<typename T>
template<typename S >
UT_Vector4T<T>& UT_Vector4T< T >::operator= ( const UT_Vector4T< S > &  v  )  [inline]

Definition at line 169 of file UT_Vector4.h.

template<typename T>
unsigned UT_Vector4T< T >::operator== ( const UT_Vector4T< T > &  v  )  const [inline]

Definition at line 205 of file UT_Vector4.h.

template<typename T>
T UT_Vector4T< T >::operator[] ( unsigned  i  )  const [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 479 of file UT_Vector4.h.

template<typename T>
T& UT_Vector4T< T >::operator[] ( unsigned  i  )  [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 474 of file UT_Vector4.h.

template<typename T>
template<typename S >
void UT_Vector4T< T >::rowVecMult ( const UT_Matrix4T< S > &  m  )  [inline]

If you need a multiplication operator that left multiplies the vector by a matrix (M * v), use the following colVecMult() functions. If you'd rather not use operator*=() for right-multiplications (v * M), use the following rowVecMult() functions.

Definition at line 273 of file UT_Vector4.h.

template<typename T>
template<typename S >
void UT_Vector4T< T >::rowVecMult3 ( const UT_Matrix4T< S > &  m  )  [inline]

This multiply will ignore the 4th component both in the vector an in the matrix. This helps when you want to avoid affecting the 'w' component. This in turns annihilates the translation components (row 4) in mat, so be careful.

Definition at line 286 of file UT_Vector4.h.

template<typename T>
bool UT_Vector4T< T >::save ( UT_JSONValue v  )  const

Methods to serialize to a JSON stream. The vector is stored as an array of 4 reals.

template<typename T>
bool UT_Vector4T< T >::save ( UT_JSONWriter w  )  const

Methods to serialize to a JSON stream. The vector is stored as an array of 4 reals.

template<typename T>
void UT_Vector4T< T >::save ( ostream &  os,
int  binary = 0 
) const

template<typename T>
T UT_Vector4T< T >::w ( void   )  const [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 463 of file UT_Vector4.h.

template<typename T>
T& UT_Vector4T< T >::w ( void   )  [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 462 of file UT_Vector4.h.

template<typename T>
T UT_Vector4T< T >::x ( void   )  const [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 457 of file UT_Vector4.h.

template<typename T>
T& UT_Vector4T< T >::x ( void   )  [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 456 of file UT_Vector4.h.

template<typename T>
T UT_Vector4T< T >::y ( void   )  const [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 459 of file UT_Vector4.h.

template<typename T>
T& UT_Vector4T< T >::y ( void   )  [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 458 of file UT_Vector4.h.

template<typename T>
T UT_Vector4T< T >::z ( void   )  const [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 461 of file UT_Vector4.h.

template<typename T>
T& UT_Vector4T< T >::z ( void   )  [inline]

Return the components of the vector. The () operator does NOT check for the boundary condition.

Definition at line 460 of file UT_Vector4.h.


Friends And Related Function Documentation

template<typename T>
ostream& operator<< ( ostream &  os,
const UT_Vector4T< T > &  v 
) [friend]

I/O friends.

Definition at line 544 of file UT_Vector4.h.


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

Generated on Mon Jan 28 00:30:22 2013 for HDK by  doxygen 1.5.9