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

#include <Vec4.h>

Public Types

using value_type = T
 
using ValueType = T
 

Public Member Functions

 Vec4 ()
 Trivial constructor, the vector is NOT initialized. More...
 
 Vec4 (T val)
 Construct a vector all of whose components have the given value. More...
 
 Vec4 (T x, T y, T z, T w)
 Constructor with four arguments, e.g. Vec4f v(1,2,3,4);. 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...
 
template<typename Other >
 Vec4 (Other val, typename std::enable_if< std::is_arithmetic< Other >::value, Conversion >::type=Conversion{})
 Construct a vector all of whose components have the given value, which may be of an arithmetic type different from this vector's value type. 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=static_cast< T >(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
 
const Vec4< T > & exp ()
 
const Vec4< T > & log ()
 
sum () const
 Return the sum of all the vector components. More...
 
product () const
 Return the product of all the vector components. More...
 
bool normalize (T eps=static_cast< T >(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...
 
Vec4< T > unitSafe () const
 return normalized this, or (1, 0, 0, 0) if this is null vector More...
 
template<typename S >
const Vec4< T > & operator*= (S scalar)
 Multiply each element of this vector by scalar. More...
 
template<typename S >
const Vec4< T > & operator*= (const Vec4< S > &v1)
 Multiply each element of this vector by the corresponding element of the given vector. More...
 
template<typename S >
const Vec4< T > & operator/= (S scalar)
 Divide each element of this vector by scalar. More...
 
template<typename S >
const Vec4< T > & operator/= (const Vec4< S > &v1)
 Divide each element of this vector by the corresponding element of the given vector. More...
 
template<typename S >
const Vec4< T > & operator+= (S scalar)
 Add scalar to each element of this vector. More...
 
template<typename S >
const Vec4< T > & operator+= (const Vec4< S > &v1)
 Add each element of the given vector to the corresponding element of this vector. More...
 
template<typename S >
const Vec4< T > & operator-= (S scalar)
 Subtract scalar from each element of this vector. More...
 
template<typename S >
const Vec4< T > & operator-= (const Vec4< S > &v1)
 Subtract each element of the given vector from the corresponding element of this vector. 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 Vec4< T > ones ()
 

Member Typedef Documentation

◆ value_type

using value_type = T

◆ ValueType

using ValueType = T

Constructor & Destructor Documentation

◆ Vec4() [1/6]

Vec4 ( )
inline

Trivial constructor, the vector is NOT initialized.

◆ Vec4() [2/6]

Vec4 ( val)
inlineexplicit

Construct a vector all of whose components have the given value.

◆ Vec4() [3/6]

Vec4 ( x,
y,
z,
w 
)
inline

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

◆ Vec4() [4/6]

Vec4 ( Source *  a)
inline

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

◆ Vec4() [5/6]

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

Conversion constructor.

◆ Vec4() [6/6]

Vec4 ( Other  val,
typename std::enable_if< std::is_arithmetic< Other >::value, Conversion >::type  = Conversion{} 
)
inlineexplicit

Construct a vector all of whose components have the given value, which may be of an arithmetic type different from this vector's value type.

Type conversion warnings are suppressed.

Member Function Documentation

◆ add()

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);

◆ asPointer() [1/2]

T* asPointer ( )
inline

◆ asPointer() [2/2]

const T* asPointer ( ) const
inline

◆ div()

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

◆ dot()

T dot ( const Vec4< T > &  v) const
inline

Dot product.

◆ eq()

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

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

◆ exp()

const Vec4<T>& exp ( )
inline

Return a reference to itself after the exponent has been applied to all the vector components.

◆ getVec3()

Vec3<T> getVec3 ( ) const
inline

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

◆ init()

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();

◆ length()

T length ( ) const
inline

Length of the vector.

◆ lengthSqr()

T lengthSqr ( ) const
inline

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

◆ log()

const Vec4<T>& log ( )
inline

Return a reference to itself after log has been applied to all the vector components.

◆ normalize()

bool normalize ( eps = static_cast<T>(1.0e-8))
inline

this = normalized this

◆ numColumns()

static unsigned numColumns ( )
inlinestatic

◆ numElements()

static unsigned numElements ( )
inlinestatic

◆ numRows()

static unsigned numRows ( )
inlinestatic

◆ ones()

static Vec4<T> ones ( )
inlinestatic

◆ operator()() [1/2]

T& operator() ( int  i)
inline

Alternative indexed reference to the elements.

◆ operator()() [2/2]

T operator() ( int  i) const
inline

Alternative indexed constant reference to the elements,.

◆ operator*=() [1/2]

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

Multiply each element of this vector by the corresponding element of the given vector.

◆ operator*=() [2/2]

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

Multiply each element of this vector by scalar.

◆ operator+=() [1/2]

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

Add each element of the given vector to the corresponding element of this vector.

◆ operator+=() [2/2]

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

Add scalar to each element of this vector.

◆ operator-()

Vec4<T> operator- ( ) const
inline

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

◆ operator-=() [1/2]

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

Subtract each element of the given vector from the corresponding element of this vector.

◆ operator-=() [2/2]

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

Subtract scalar from each element of this vector.

◆ operator/=() [1/2]

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

Divide each element of this vector by the corresponding element of the given vector.

◆ operator/=() [2/2]

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

Divide each element of this vector by scalar.

◆ operator=()

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

Assignment operator.

◆ origin()

static Vec4<T> origin ( )
inlinestatic

◆ product()

T product ( ) const
inline

Return the product of all the vector components.

◆ scale()

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);

◆ setZero()

const Vec4<T>& setZero ( )
inline

Set "this" vector to zero.

◆ sub()

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);

◆ sum()

T sum ( ) const
inline

Return the sum of all the vector components.

◆ unit() [1/2]

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

return normalized this and length, throws if null vector

◆ unit() [2/2]

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

return normalized this, throws if null vector

◆ unitSafe()

Vec4<T> unitSafe ( ) const
inline

return normalized this, or (1, 0, 0, 0) if this is null vector

◆ w() [1/2]

T& w ( )
inline

◆ w() [2/2]

T w ( ) const
inline

◆ x() [1/2]

T& x ( )
inline

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

◆ x() [2/2]

T x ( ) const
inline

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

◆ y() [1/2]

T& y ( )
inline

◆ y() [2/2]

T y ( ) const
inline

◆ z() [1/2]

T& z ( )
inline

◆ z() [2/2]

T z ( ) const
inline

◆ zero()

static Vec4<T> zero ( )
inlinestatic

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


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