OpenVDB  2.1.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
Vec4< T > Class Template Reference

#include <Mat4.h>

Inherits Tuple< 4, T >.

Public Types

typedef T value_type
 
typedef T ValueType
 

Public Member Functions

 Vec4 ()
 Trivial constructor, the vector is NOT initialized. More...
 
 Vec4 (T val)
 Constructor with one argument, e.g. Vec4f v(0);. More...
 
 Vec4 (T x, T y, T z, T w)
 Constructor with three arguments, e.g. Vec4f v(1,2,3);. More...
 
template<typename Source >
 Vec4 (Source *a)
 Constructor with array argument, e.g. float a[4]; Vec4f v(a);. More...
 
template<typename Source >
 Vec4 (const Tuple< 4, Source > &v)
 Conversion constructor. More...
 
T & x ()
 Reference to the component, e.g. v.x() = 4.5f;. More...
 
T & y ()
 
T & z ()
 
T & w ()
 
x () const
 Get the component, e.g. float f = v.y();. More...
 
y () const
 
z () const
 
w () const
 
T * asPointer ()
 
const T * asPointer () const
 
T & operator() (int i)
 Alternative indexed reference to the elements. More...
 
operator() (int i) const
 Alternative indexed constant reference to the elements,. More...
 
Vec3< T > getVec3 () const
 Returns a Vec3 with the first three elements of the Vec4. More...
 
const Vec4< T > & init (T x=0, T y=0, T z=0, T w=0)
 
const Vec4< T > & setZero ()
 Set "this" vector to zero. More...
 
template<typename Source >
const Vec4< T > & operator= (const Vec4< Source > &v)
 Assignment operator. More...
 
bool eq (const Vec4< T > &v, T eps=1.0e-8) const
 
Vec4< T > operator- () const
 Negation operator, for e.g. v1 = -v2;. More...
 
template<typename T0 , typename T1 >
const Vec4< T > & add (const Vec4< T0 > &v1, const Vec4< T1 > &v2)
 
template<typename T0 , typename T1 >
const Vec4< T > & sub (const Vec4< T0 > &v1, const Vec4< T1 > &v2)
 
template<typename T0 , typename T1 >
const Vec4< T > & scale (T0 scale, const Vec4< T1 > &v)
 
template<typename T0 , typename T1 >
const Vec4< T > & div (T0 scalar, const Vec4< T1 > &v)
 
dot (const Vec4< T > &v) const
 Dot product. More...
 
length () const
 Length of the vector. More...
 
lengthSqr () const
 
bool normalize (T eps=1.0e-8)
 this = normalized this More...
 
Vec4< T > unit (T eps=0) const
 return normalized this, throws if null vector More...
 
Vec4< T > unit (T eps, T &len) const
 return normalized this and length, throws if null vector More...
 
template<typename S >
const Vec4< T > & operator*= (S scalar)
 Returns v, where $v_i *= scalar$ for $i \in [0, 3]$. More...
 
template<typename S >
const Vec4< T > & operator*= (const Vec4< S > &v1)
 Returns v0, where $v0_i *= v1_i$ for $i \in [0, 3]$. More...
 
template<typename S >
const Vec4< T > & operator/= (S scalar)
 Returns v, where $v_i /= scalar$ for $i \in [0, 3]$. More...
 
template<typename S >
const Vec4< T > & operator/= (const Vec4< S > &v1)
 Returns v0, where $v0_i /= v1_i$ for $i \in [0, 3]$. More...
 
template<typename S >
const Vec4< T > & operator+= (S scalar)
 Returns v, where $v_i += scalar$ for $i \in [0, 3]$. More...
 
template<typename S >
const Vec4< T > & operator+= (const Vec4< S > &v1)
 Returns v0, where $v0_i += v1_i$ for $i \in [0, 3]$. More...
 
template<typename S >
const Vec4< T > & operator-= (S scalar)
 Returns v, where $v_i += scalar$ for $i \in [0, 3]$. More...
 
template<typename S >
const Vec4< T > & operator-= (const Vec4< S > &v1)
 Returns v0, where $v0_i -= v1_i$ for $i \in [0, 3]$. More...
 
bool isNan () const
 True if a Nan is present in vector. More...
 
bool isInfinite () const
 True if an Inf is present in vector. More...
 
bool isFinite () const
 True if all no Nan or Inf values present. More...
 
operator[] (int i) const
 
T & operator[] (int i)
 
std::string str () const
 
void write (std::ostream &os) const
 
void read (std::istream &is)
 
Compatibility

These are mostly for backwards compability with functions that take old-style Vs (which are just arrays).

void toV (S *v) const
 Copies this tuple into an array of a compatible type. More...
 
value_typeasV ()
 Exposes the internal array. Be careful when using this function. More...
 
value_type const * asV () const
 Exposes the internal array. Be careful when using this function. More...
 

Static Public Member Functions

static unsigned numRows ()
 
static unsigned numColumns ()
 
static unsigned numElements ()
 
static Vec4< T > zero ()
 Predefined constants, e.g. Vec4f v = Vec4f::xNegAxis();. More...
 
static Vec4< T > origin ()
 

Static Public Attributes

static const int size
 

Protected Attributes

mm [SIZE]
 

Member Typedef Documentation

typedef T value_type
typedef T ValueType

Constructor & Destructor Documentation

Vec4 ( )
inline

Trivial constructor, the vector is NOT initialized.

Vec4 ( val)
inlineexplicit

Constructor with one argument, e.g. Vec4f v(0);.

Vec4 ( x,
y,
z,
w 
)
inline

Constructor with three arguments, e.g. Vec4f v(1,2,3);.

Vec4 ( Source *  a)
inline

Constructor with array argument, e.g. float a[4]; Vec4f v(a);.

Vec4 ( const Tuple< 4, Source > &  v)
inlineexplicit

Conversion constructor.

Member Function Documentation

const Vec4<T>& add ( const Vec4< T0 > &  v1,
const Vec4< T1 > &  v2 
)
inline

this = v1 + v2 "this", v1 and v2 need not be distinct objects, e.g. v.add(v1,v);

T* asPointer ( )
inline
const T* asPointer ( ) const
inline
value_type* asV ( )
inlineinherited

Exposes the internal array. Be careful when using this function.

value_type const* asV ( ) const
inlineinherited

Exposes the internal array. Be careful when using this function.

const Vec4<T>& div ( T0  scalar,
const Vec4< T1 > &  v 
)
inline
T dot ( const Vec4< T > &  v) const
inline

Dot product.

bool eq ( const Vec4< T > &  v,
eps = 1.0e-8 
) const
inline

Test if "this" vector is equivalent to vector v with tolerance of eps

Vec3<T> getVec3 ( ) const
inline

Returns a Vec3 with the first three elements of the Vec4.

const Vec4<T>& init ( x = 0,
y = 0,
z = 0,
w = 0 
)
inline

"this" vector gets initialized to [x, y, z, w], calling v.init(); has same effect as calling v = Vec4::zero();

bool isFinite ( ) const
inline

True if all no Nan or Inf values present.

bool isInfinite ( ) const
inline

True if an Inf is present in vector.

bool isNan ( ) const
inline

True if a Nan is present in vector.

T length ( ) const
inline

Length of the vector.

T lengthSqr ( ) const
inline

Squared length of the vector, much faster than length() as it does not involve square root

bool normalize ( eps = 1.0e-8)
inline

this = normalized this

static unsigned numColumns ( )
inlinestatic
static unsigned numElements ( )
inlinestatic
static unsigned numRows ( )
inlinestatic
T& operator() ( int  i)
inline

Alternative indexed reference to the elements.

T operator() ( int  i) const
inline

Alternative indexed constant reference to the elements,.

const Vec4<T>& operator*= ( scalar)
inline

Returns v, where $v_i *= scalar$ for $i \in [0, 3]$.

const Vec4<T>& operator*= ( const Vec4< S > &  v1)
inline

Returns v0, where $v0_i *= v1_i$ for $i \in [0, 3]$.

const Vec4<T>& operator+= ( scalar)
inline

Returns v, where $v_i += scalar$ for $i \in [0, 3]$.

const Vec4<T>& operator+= ( const Vec4< S > &  v1)
inline

Returns v0, where $v0_i += v1_i$ for $i \in [0, 3]$.

Vec4<T> operator- ( ) const
inline

Negation operator, for e.g. v1 = -v2;.

const Vec4<T>& operator-= ( scalar)
inline

Returns v, where $v_i += scalar$ for $i \in [0, 3]$.

const Vec4<T>& operator-= ( const Vec4< S > &  v1)
inline

Returns v0, where $v0_i -= v1_i$ for $i \in [0, 3]$.

const Vec4<T>& operator/= ( scalar)
inline

Returns v, where $v_i /= scalar$ for $i \in [0, 3]$.

const Vec4<T>& operator/= ( const Vec4< S > &  v1)
inline

Returns v0, where $v0_i /= v1_i$ for $i \in [0, 3]$.

const Vec4<T>& operator= ( const Vec4< Source > &  v)
inline

Assignment operator.

T operator[] ( int  i) const
inlineinherited
T& operator[] ( int  i)
inlineinherited
static Vec4<T> origin ( )
inlinestatic
void read ( std::istream &  is)
inlineinherited
const Vec4<T>& scale ( T0  scale,
const Vec4< T1 > &  v 
)
inline

this = scalar*v, v need not be a distinct object from "this", e.g. v.scale(1.5,v1);

const Vec4<T>& setZero ( )
inline

Set "this" vector to zero.

std::string str ( ) const
inlineinherited
Returns
string representation of Classname
const Vec4<T>& sub ( const Vec4< T0 > &  v1,
const Vec4< T1 > &  v2 
)
inline

this = v1 - v2 "this", v1 and v2 need not be distinct objects, e.g. v.sub(v1,v);

void toV ( S *  v) const
inlineinherited

Copies this tuple into an array of a compatible type.

Vec4<T> unit ( eps = 0) const
inline

return normalized this, throws if null vector

Vec4<T> unit ( eps,
T &  len 
) const
inline

return normalized this and length, throws if null vector

T& w ( )
inline
T w ( ) const
inline
void write ( std::ostream &  os) const
inlineinherited
T& x ( )
inline

Reference to the component, e.g. v.x() = 4.5f;.

T x ( ) const
inline

Get the component, e.g. float f = v.y();.

T& y ( )
inline
T y ( ) const
inline
T& z ( )
inline
T z ( ) const
inline
static Vec4<T> zero ( )
inlinestatic

Predefined constants, e.g. Vec4f v = Vec4f::xNegAxis();.

Member Data Documentation

T mm[SIZE]
protectedinherited
const int size
staticinherited

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