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

#include <Mat.h>

Inherits Tuple< 3, T >.

Public Types

typedef T value_type
 
typedef T ValueType
 

Public Member Functions

 Vec3 ()
 Trivial constructor, the vector is NOT initialized. More...
 
 Vec3 (T val)
 Constructor with one argument, e.g. Vec3f v(0);. More...
 
 Vec3 (T x, T y, T z)
 Constructor with three arguments, e.g. Vec3d v(1,2,3);. More...
 
template<typename Source >
 Vec3 (Source *a)
 Constructor with array argument, e.g. double a[3]; Vec3d v(a);. More...
 
template<typename Source >
 Vec3 (const Tuple< 3, Source > &v)
 Construct a Vec3 from a 3-Tuple with a possibly different value type. More...
 
template<typename Other >
 Vec3 (const Vec3< Other > &v)
 Construct a Vec3 from another Vec3 with a possibly different value type. More...
 
T & x ()
 Reference to the component, e.g. v.x() = 4.5f;. More...
 
T & y ()
 
T & z ()
 
x () const
 Get the component, e.g. float f = v.y();. More...
 
y () const
 
z () 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...
 
const Vec3< T > & init (T x=0, T y=0, T z=0)
 
const Vec3< T > & setZero ()
 Set "this" vector to zero. More...
 
template<typename Source >
const Vec3< T > & operator= (const Vec3< Source > &v)
 Assignment operator. More...
 
bool eq (const Vec3< T > &v, T eps=static_cast< T >(1.0e-7)) const
 Test if "this" vector is equivalent to vector v with tolerance of eps. More...
 
Vec3< T > operator- () const
 Negation operator, for e.g. v1 = -v2;. More...
 
template<typename T0 , typename T1 >
const Vec3< T > & add (const Vec3< T0 > &v1, const Vec3< T1 > &v2)
 
template<typename T0 , typename T1 >
const Vec3< T > & sub (const Vec3< T0 > &v1, const Vec3< T1 > &v2)
 
template<typename T0 , typename T1 >
const Vec3< T > & scale (T0 scale, const Vec3< T1 > &v)
 
template<typename T0 , typename T1 >
const Vec3< T > & div (T0 scale, const Vec3< T1 > &v)
 
dot (const Vec3< T > &v) const
 Dot product. More...
 
length () const
 Length of the vector. More...
 
lengthSqr () const
 
Vec3< T > cross (const Vec3< T > &v) const
 Return the cross product of "this" vector and v;. More...
 
const Vec3< T > & cross (const Vec3< T > &v1, const Vec3< T > &v2)
 this = v1 cross v2, v1 and v2 must be distinct objects than "this" More...
 
template<typename S >
const Vec3< T > & operator*= (S scalar)
 Returns v, where $v_i *= scalar$ for $i \in [0, 2]$. More...
 
template<typename S >
const Vec3< T > & operator*= (const Vec3< S > &v1)
 Returns v0, where $v0_i *= v1_i$ for $i \in [0, 2]$. More...
 
template<typename S >
const Vec3< T > & operator/= (S scalar)
 Returns v, where $v_i /= scalar$ for $i \in [0, 2]$. More...
 
template<typename S >
const Vec3< T > & operator/= (const Vec3< S > &v1)
 Returns v0, where $v0_i /= v1_i$ for $i \in [0, 2]$. More...
 
template<typename S >
const Vec3< T > & operator+= (S scalar)
 Returns v, where $v_i += scalar$ for $i \in [0, 2]$. More...
 
template<typename S >
const Vec3< T > & operator+= (const Vec3< S > &v1)
 Returns v0, where $v0_i += v1_i$ for $i \in [0, 2]$. More...
 
template<typename S >
const Vec3< T > & operator-= (S scalar)
 Returns v, where $v_i += scalar$ for $i \in [0, 2]$. More...
 
template<typename S >
const Vec3< T > & operator-= (const Vec3< S > &v1)
 Returns v0, where $v0_i -= v1_i$ for $i \in [0, 2]$. More...
 
const Vec3< T > & exp ()
 
sum () const
 Return the sum of all the vector components. More...
 
bool normalize (T eps=T(1.0e-7))
 this = normalized this More...
 
Vec3< T > unit (T eps=0) const
 return normalized this, throws if null vector More...
 
Vec3< T > unit (T eps, T &len) const
 return normalized this and length, throws if null vector More...
 
component (const Vec3< T > &onto, T eps=static_cast< T >(1.0e-7)) const
 
Vec3< T > projection (const Vec3< T > &onto, T eps=static_cast< T >(1.0e-7)) const
 
Vec3< T > getArbPerpendicular () const
 
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 Vec3< T > zero ()
 Predefined constants, e.g. Vec3d v = Vec3d::xNegAxis();. More...
 

Static Public Attributes

static const int size
 

Protected Attributes

mm [SIZE]
 

Member Typedef Documentation

◆ value_type

typedef T value_type

◆ ValueType

typedef T ValueType

Constructor & Destructor Documentation

◆ Vec3() [1/6]

Vec3 ( )
inline

Trivial constructor, the vector is NOT initialized.

◆ Vec3() [2/6]

Vec3 ( val)
inlineexplicit

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

◆ Vec3() [3/6]

Vec3 ( x,
y,
z 
)
inline

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

◆ Vec3() [4/6]

Vec3 ( Source *  a)
inline

Constructor with array argument, e.g. double a[3]; Vec3d v(a);.

◆ Vec3() [5/6]

Vec3 ( const Tuple< 3, Source > &  v)
inlineexplicit

Construct a Vec3 from a 3-Tuple with a possibly different value type.

Type conversion warnings are suppressed.

◆ Vec3() [6/6]

Vec3 ( const Vec3< Other > &  v)
inline

Construct a Vec3 from another Vec3 with a possibly different value type.

Type conversion warnings are suppressed.

Member Function Documentation

◆ add()

const Vec3<T>& add ( const Vec3< T0 > &  v1,
const Vec3< 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

◆ asV() [1/2]

value_type* asV ( )
inlineinherited

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

◆ asV() [2/2]

value_type const* asV ( ) const
inlineinherited

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

◆ component()

T component ( const Vec3< T > &  onto,
eps = static_cast<T>(1.0e-7) 
) const
inline

Returns the scalar component of v in the direction of onto, onto need not be unit. e.g double c = Vec3d::component(v1,v2);

◆ cross() [1/2]

Vec3<T> cross ( const Vec3< T > &  v) const
inline

Return the cross product of "this" vector and v;.

◆ cross() [2/2]

const Vec3<T>& cross ( const Vec3< T > &  v1,
const Vec3< T > &  v2 
)
inline

this = v1 cross v2, v1 and v2 must be distinct objects than "this"

◆ div()

const Vec3<T>& div ( T0  scale,
const Vec3< T1 > &  v 
)
inline

◆ dot()

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

Dot product.

◆ eq()

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

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

◆ exp()

const Vec3<T>& exp ( )
inline

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

◆ getArbPerpendicular()

Vec3<T> getArbPerpendicular ( ) const
inline

Return an arbitrary unit vector perpendicular to v Vector this must be a unit vector e.g. v = v.normalize(); Vec3d n = v.getArbPerpendicular();

◆ init()

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

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

◆ isFinite()

bool isFinite ( ) const
inline

True if all no Nan or Inf values present.

◆ isInfinite()

bool isInfinite ( ) const
inline

True if an Inf is present in vector.

◆ isNan()

bool isNan ( ) const
inline

True if a Nan is present in vector.

◆ 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

◆ normalize()

bool normalize ( eps = T(1.0e-7))
inline

this = normalized this

◆ numColumns()

static unsigned numColumns ( )
inlinestatic

◆ numElements()

static unsigned numElements ( )
inlinestatic

◆ numRows()

static unsigned numRows ( )
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 Vec3<T>& operator*= ( scalar)
inline

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

◆ operator*=() [2/2]

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

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

◆ operator+=() [1/2]

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

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

◆ operator+=() [2/2]

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

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

◆ operator-()

Vec3<T> operator- ( ) const
inline

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

◆ operator-=() [1/2]

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

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

◆ operator-=() [2/2]

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

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

◆ operator/=() [1/2]

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

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

◆ operator/=() [2/2]

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

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

◆ operator=()

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

Assignment operator.

Type conversion warnings are not suppressed.

◆ operator[]() [1/2]

T operator[] ( int  i) const
inlineinherited

◆ operator[]() [2/2]

T& operator[] ( int  i)
inlineinherited

◆ projection()

Vec3<T> projection ( const Vec3< T > &  onto,
eps = static_cast<T>(1.0e-7) 
) const
inline

Return the projection of v onto the vector, onto need not be unit e.g. Vec3d a = vprojection(n);

◆ read()

void read ( std::istream &  is)
inlineinherited

◆ scale()

const Vec3<T>& scale ( T0  scale,
const Vec3< T1 > &  v 
)
inline

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

◆ setZero()

const Vec3<T>& setZero ( )
inline

Set "this" vector to zero.

◆ str()

std::string str ( ) const
inlineinherited
Returns
string representation of Classname

◆ sub()

const Vec3<T>& sub ( const Vec3< T0 > &  v1,
const Vec3< 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.

◆ toV()

void toV ( S *  v) const
inlineinherited

Copies this tuple into an array of a compatible type.

◆ unit() [1/2]

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

return normalized this, throws if null vector

◆ unit() [2/2]

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

return normalized this and length, throws if null vector

◆ write()

void write ( std::ostream &  os) const
inlineinherited

◆ 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 Vec3<T> zero ( )
inlinestatic

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

Member Data Documentation

◆ mm

T mm[SIZE]
protectedinherited

◆ size

const int size
staticinherited

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