HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
openvdb::OPENVDB_VERSION_NAME::math::Vec2< T > Class Template Reference

#include <Vec2.h>

+ Inheritance diagram for openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >:

Public Types

using value_type = T
 
using ValueType = T
 
- Public Types inherited from openvdb::OPENVDB_VERSION_NAME::math::Tuple< 2, T >
using value_type = T
 
using ValueType = T
 

Public Member Functions

 Vec2 ()
 Trivial constructor, the vector is NOT initialized. More...
 
 Vec2 (T val)
 Construct a vector all of whose components have the given value. More...
 
 Vec2 (T x, T y)
 Constructor with two arguments, e.g. Vec2f v(1,2,3);. More...
 
template<typename Source >
 Vec2 (Source *a)
 Constructor with array argument, e.g. float a[2]; Vec2f v(a);. More...
 
template<typename Source >
 Vec2 (const Tuple< 2, Source > &t)
 Conversion constructor. More...
 
template<typename Other >
 Vec2 (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 ()
 
x () const
 Get the component, e.g. float f = v.y();. More...
 
y () const
 
T & operator() (int i)
 Alternative indexed reference to the elements. More...
 
operator() (int i) const
 Alternative indexed constant reference to the elements,. More...
 
T * asPointer ()
 
const T * asPointer () const
 
const Vec2< T > & init (T x=0, T y=0)
 
const Vec2< T > & setZero ()
 Set "this" vector to zero. More...
 
template<typename Source >
const Vec2< T > & operator= (const Vec2< Source > &v)
 Assignment operator. More...
 
bool operator== (const Vec2< T > &v) const
 Equality operator, does exact floating point comparisons. More...
 
bool operator!= (const Vec2< T > &v) const
 Inequality operator, does exact floating point comparisons. More...
 
bool eq (const Vec2< 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...
 
Vec2< T > operator- () const
 Negation operator, for e.g. v1 = -v2;. More...
 
template<typename T0 , typename T1 >
const Vec2< T > & add (const Vec2< T0 > &v1, const Vec2< T1 > &v2)
 
template<typename T0 , typename T1 >
const Vec2< T > & sub (const Vec2< T0 > &v1, const Vec2< T1 > &v2)
 
template<typename T0 , typename T1 >
const Vec2< T > & scale (T0 scalar, const Vec2< T1 > &v)
 
template<typename T0 , typename T1 >
const Vec2< T > & div (T0 scalar, const Vec2< T1 > &v)
 
dot (const Vec2< T > &v) const
 Dot product. More...
 
length () const
 Length of the vector. More...
 
lengthSqr () const
 
const Vec2< T > & exp ()
 
const Vec2< 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...
 
Vec2< T > unit (T eps=0) const
 return normalized this, throws if null vector More...
 
Vec2< T > unit (T eps, T &len) const
 return normalized this and length, throws if null vector More...
 
Vec2< T > unitSafe () const
 return normalized this, or (1, 0) if this is null vector More...
 
template<typename S >
const Vec2< T > & operator*= (S scalar)
 Multiply each element of this vector by scalar. More...
 
template<typename S >
const Vec2< T > & operator*= (const Vec2< S > &v1)
 Multiply each element of this vector by the corresponding element of the given vector. More...
 
template<typename S >
const Vec2< T > & operator/= (S scalar)
 Divide each element of this vector by scalar. More...
 
template<typename S >
const Vec2< T > & operator/= (const Vec2< S > &v1)
 Divide each element of this vector by the corresponding element of the given vector. More...
 
template<typename S >
const Vec2< T > & operator+= (S scalar)
 Add scalar to each element of this vector. More...
 
template<typename S >
const Vec2< T > & operator+= (const Vec2< S > &v1)
 Add each element of the given vector to the corresponding element of this vector. More...
 
template<typename S >
const Vec2< T > & operator-= (S scalar)
 Subtract scalar from each element of this vector. More...
 
template<typename S >
const Vec2< T > & operator-= (const Vec2< S > &v1)
 Subtract each element of the given vector from the corresponding element of this vector. More...
 
component (const Vec2< T > &onto, T eps=static_cast< T >(1.0e-8)) const
 
Vec2< T > projection (const Vec2< T > &onto, T eps=static_cast< T >(1.0e-8)) const
 
Vec2< T > getArbPerpendicular () const
 
- Public Member Functions inherited from openvdb::OPENVDB_VERSION_NAME::math::Tuple< 2, T >
 Tuple ()
 Default ctor. Does nothing. More...
 
 Tuple (Tuple const &src)
 Copy constructor. Used when the class signature matches exactly. More...
 
 Tuple (Tuple< src_size, src_valtype > const &src)
 Conversion constructor. More...
 
Tupleoperator= (Tuple const &src)
 Assignment operator. More...
 
T operator[] (int i) const
 
Toperator[] (int i)
 
std::string str () const
 
void write (std::ostream &os) const
 
void read (std::istream &is)
 
bool isNan () const
 True if a Nan is present in this tuple. More...
 
bool isInfinite () const
 True if an Inf is present in this tuple. More...
 
bool isFinite () const
 True if no Nan or Inf values are present. More...
 
bool isZero () const
 True if all elements are exactly zero. More...
 
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 constasV () 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 Vec2< T > zero ()
 Predefined constants, e.g. Vec2f v = Vec2f::xNegAxis();. More...
 
static Vec2< T > ones ()
 

Additional Inherited Members

- Static Public Attributes inherited from openvdb::OPENVDB_VERSION_NAME::math::Tuple< 2, T >
static const int size
 
- Protected Attributes inherited from openvdb::OPENVDB_VERSION_NAME::math::Tuple< 2, T >
T mm [SIZE]
 

Detailed Description

template<typename T>
class openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >

Definition at line 23 of file Vec2.h.

Member Typedef Documentation

template<typename T>
using openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::value_type = T

Definition at line 26 of file Vec2.h.

template<typename T>
using openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::ValueType = T

Definition at line 27 of file Vec2.h.

Constructor & Destructor Documentation

template<typename T>
openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::Vec2 ( )
inline

Trivial constructor, the vector is NOT initialized.

Definition at line 30 of file Vec2.h.

template<typename T>
openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::Vec2 ( val)
inlineexplicit

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

Definition at line 33 of file Vec2.h.

template<typename T>
openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::Vec2 ( x,
y 
)
inline

Constructor with two arguments, e.g. Vec2f v(1,2,3);.

Definition at line 36 of file Vec2.h.

template<typename T>
template<typename Source >
openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::Vec2 ( Source *  a)
inline

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

Definition at line 44 of file Vec2.h.

template<typename T>
template<typename Source >
openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::Vec2 ( const Tuple< 2, Source > &  t)
inlineexplicit

Conversion constructor.

Definition at line 52 of file Vec2.h.

template<typename T>
template<typename Other >
openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::Vec2 ( 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.

Definition at line 62 of file Vec2.h.

Member Function Documentation

template<typename T>
template<typename T0 , typename T1 >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::add ( const Vec2< T0 > &  v1,
const Vec2< T1 > &  v2 
)
inline

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

Definition at line 133 of file Vec2.h.

template<typename T>
T* openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::asPointer ( )
inline

Definition at line 82 of file Vec2.h.

template<typename T>
const T* openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::asPointer ( ) const
inline

Definition at line 83 of file Vec2.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::component ( const Vec2< T > &  onto,
eps = static_cast<T>(1.0e-8) 
) const
inline

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

Definition at line 329 of file Vec2.h.

template<typename T>
template<typename T0 , typename T1 >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::div ( T0  scalar,
const Vec2< T1 > &  v 
)
inline

Definition at line 164 of file Vec2.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::dot ( const Vec2< T > &  v) const
inline

Dot product.

Definition at line 173 of file Vec2.h.

template<typename T>
bool openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::eq ( const Vec2< T > &  v,
eps = static_cast<T>(1.0e-7) 
) const
inline

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

Definition at line 121 of file Vec2.h.

template<typename T>
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::exp ( )
inline

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

Definition at line 187 of file Vec2.h.

template<typename T>
Vec2<T> openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::getArbPerpendicular ( ) const
inline

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

Definition at line 350 of file Vec2.h.

template<typename T>
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::init ( x = 0,
y = 0 
)
inline

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

Definition at line 87 of file Vec2.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::length ( void  ) const
inline

Length of the vector.

Definition at line 176 of file Vec2.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::lengthSqr ( ) const
inline

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

Definition at line 183 of file Vec2.h.

template<typename T>
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::log ( )
inline

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

Definition at line 196 of file Vec2.h.

template<typename T>
bool openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::normalize ( eps = static_cast<T>(1.0e-8))
inline

this = normalized this

Definition at line 216 of file Vec2.h.

template<typename T>
static unsigned openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::numColumns ( )
inlinestatic

Definition at line 324 of file Vec2.h.

template<typename T>
static unsigned openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::numElements ( )
inlinestatic

Definition at line 325 of file Vec2.h.

template<typename T>
static unsigned openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::numRows ( )
inlinestatic

Definition at line 323 of file Vec2.h.

template<typename T>
static Vec2<T> openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::ones ( )
inlinestatic

Definition at line 354 of file Vec2.h.

template<typename T>
bool openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator!= ( const Vec2< T > &  v) const
inline

Inequality operator, does exact floating point comparisons.

Definition at line 118 of file Vec2.h.

template<typename T>
T& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator() ( int  i)
inline

Alternative indexed reference to the elements.

Definition at line 77 of file Vec2.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator() ( int  i) const
inline

Alternative indexed constant reference to the elements,.

Definition at line 80 of file Vec2.h.

template<typename T>
template<typename S >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator*= ( scalar)
inline

Multiply each element of this vector by scalar.

Definition at line 252 of file Vec2.h.

template<typename T>
template<typename S >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator*= ( const Vec2< S > &  v1)
inline

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

Definition at line 261 of file Vec2.h.

template<typename T>
template<typename S >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator+= ( scalar)
inline

Add scalar to each element of this vector.

Definition at line 288 of file Vec2.h.

template<typename T>
template<typename S >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator+= ( const Vec2< S > &  v1)
inline

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

Definition at line 297 of file Vec2.h.

template<typename T>
Vec2<T> openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator- ( ) const
inline

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

Definition at line 128 of file Vec2.h.

template<typename T>
template<typename S >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator-= ( scalar)
inline

Subtract scalar from each element of this vector.

Definition at line 306 of file Vec2.h.

template<typename T>
template<typename S >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator-= ( const Vec2< S > &  v1)
inline

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

Definition at line 315 of file Vec2.h.

template<typename T>
template<typename S >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator/= ( scalar)
inline

Divide each element of this vector by scalar.

Definition at line 270 of file Vec2.h.

template<typename T>
template<typename S >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator/= ( const Vec2< S > &  v1)
inline

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

Definition at line 279 of file Vec2.h.

template<typename T>
template<typename Source >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator= ( const Vec2< Source > &  v)
inline

Assignment operator.

Definition at line 102 of file Vec2.h.

template<typename T>
bool openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::operator== ( const Vec2< T > &  v) const
inline

Equality operator, does exact floating point comparisons.

Definition at line 112 of file Vec2.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::product ( ) const
inline

Return the product of all the vector components.

Definition at line 210 of file Vec2.h.

template<typename T>
Vec2<T> openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::projection ( const Vec2< T > &  onto,
eps = static_cast<T>(1.0e-8) 
) const
inline

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

Definition at line 339 of file Vec2.h.

template<typename T>
template<typename T0 , typename T1 >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::scale ( T0  scalar,
const Vec2< T1 > &  v 
)
inline

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

Definition at line 155 of file Vec2.h.

template<typename T>
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::setZero ( )
inline

Set "this" vector to zero.

Definition at line 94 of file Vec2.h.

template<typename T>
template<typename T0 , typename T1 >
const Vec2<T>& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::sub ( const Vec2< T0 > &  v1,
const Vec2< T1 > &  v2 
)
inline

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

Definition at line 144 of file Vec2.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::sum ( ) const
inline

Return the sum of all the vector components.

Definition at line 204 of file Vec2.h.

template<typename T>
Vec2<T> openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::unit ( eps = 0) const
inline

return normalized this, throws if null vector

Definition at line 227 of file Vec2.h.

template<typename T>
Vec2<T> openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::unit ( eps,
T &  len 
) const
inline

return normalized this and length, throws if null vector

Definition at line 234 of file Vec2.h.

template<typename T>
Vec2<T> openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::unitSafe ( ) const
inline

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

Definition at line 244 of file Vec2.h.

template<typename T>
T& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::x ( )
inline

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

Definition at line 69 of file Vec2.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::x ( ) const
inline

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

Definition at line 73 of file Vec2.h.

template<typename T>
T& openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::y ( )
inline

Definition at line 70 of file Vec2.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::y ( ) const
inline

Definition at line 74 of file Vec2.h.

template<typename T>
static Vec2<T> openvdb::OPENVDB_VERSION_NAME::math::Vec2< T >::zero ( )
inlinestatic

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

Definition at line 353 of file Vec2.h.


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