HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Vector2T< T > Class Template Reference

2D Vector class. More...

#include <UT_Vector2.h>

Public Types

typedef T value_type
 

Public Member Functions

constexpr SYS_FORCE_INLINE UT_Vector2T ()=default
 
constexpr SYS_FORCE_INLINE UT_Vector2T (const UT_Vector2T< T > &that)=default
 
constexpr SYS_FORCE_INLINE UT_Vector2T (UT_Vector2T< T > &&that)=default
 
constexpr SYS_FORCE_INLINE UT_Vector2T (const T vx, const T vy) noexcept
 
constexpr SYS_FORCE_INLINE UT_Vector2T (T v) noexcept
 
constexpr SYS_FORCE_INLINE UT_Vector2T (const fpreal16 v[]) noexcept
 
constexpr SYS_FORCE_INLINE UT_Vector2T (const fpreal32 v[]) noexcept
 
constexpr SYS_FORCE_INLINE UT_Vector2T (const fpreal64 v[]) noexcept
 
constexpr SYS_FORCE_INLINE UT_Vector2T (const int32 v[]) noexcept
 
constexpr SYS_FORCE_INLINE UT_Vector2T (const int64 v[]) noexcept
 
constexpr UT_Vector2T (const UT_Vector3T< T > &v) noexcept
 
constexpr UT_Vector2T (const UT_Vector4T< T > &v) noexcept
 
template<typename S >
constexpr SYS_FORCE_INLINE UT_Vector2T (const UT_Vector2T< S > &v) noexcept
 Our own type of any given value_type. More...
 
constexpr SYS_FORCE_INLINE UT_Vector2T (const UT_FixedVector< T, tuple_size > &v) noexcept
 UT_FixedVector of the same size. More...
 
constexpr SYS_FORCE_INLINE
UT_Vector2T< T > & 
operator= (const UT_Vector2T< T > &that)=default
 
constexpr SYS_FORCE_INLINE
UT_Vector2T< T > & 
operator= (UT_Vector2T< T > &&that)=default
 
template<typename S >
constexpr SYS_FORCE_INLINE
UT_Vector2T< T > & 
operator= (const UT_Vector2T< S > &v)
 
constexpr SYS_FORCE_INLINE
const T
data () const noexcept
 
constexpr SYS_FORCE_INLINE Tdata () noexcept
 
constexpr SYS_FORCE_INLINE
const T
operator[] (exint i) const noexcept
 
constexpr SYS_FORCE_INLINE Toperator[] (exint i) noexcept
 
constexpr SYS_FORCE_INLINE
UT_Vector2T
operator+= (const UT_Vector2T &a) noexcept
 
constexpr SYS_FORCE_INLINE
UT_Vector2T
operator-= (const UT_Vector2T &a) noexcept
 
constexpr SYS_FORCE_INLINE
UT_Vector2T
operator+= (const T &a) noexcept
 
constexpr SYS_FORCE_INLINE
UT_Vector2T
operator-= (const T &a) noexcept
 
constexpr SYS_FORCE_INLINE
UT_Vector2T
operator*= (const T &a) noexcept
 
constexpr SYS_FORCE_INLINE
UT_Vector2T
operator/= (const T &a) noexcept
 
constexpr SYS_FORCE_INLINE
UT_Vector2T
operator*= (const UT_Vector2T &a) noexcept
 
constexpr SYS_FORCE_INLINE void negate () noexcept
 
constexpr SYS_FORCE_INLINE T length2 () const noexcept
 
constexpr SYS_FORCE_INLINE T length () const noexcept
 
constexpr SYS_FORCE_INLINE T distance2 (const UT_Vector2T &b) const noexcept
 
constexpr SYS_FORCE_INLINE T distance (const UT_Vector2T &b) const noexcept
 
SYS_FORCE_INLINE
UT_StorageMathFloat_t< T
normalize () noexcept
 
constexpr SYS_FORCE_INLINE bool isNan () const noexcept
 
constexpr SYS_FORCE_INLINE bool isFinite () const noexcept
 
constexpr SYS_FORCE_INLINE bool isZero () const noexcept
 
constexpr SYS_FORCE_INLINE bool equalZero (const T tolerance=SYS_FTOLERANCE) const noexcept
 
constexpr SYS_FORCE_INLINE bool isEqual (const UT_Vector2T &b, const T tolerance=SYS_FTOLERANCE) const noexcept
 
constexpr SYS_FORCE_INLINE T maxComponent () const noexcept
 
UT_Vector2T< T > & operator= (const UT_Vector3T< T > &v)
 Assignment operator that truncates a V3 to a V2. More...
 
UT_Vector2T< T > & operator= (const UT_Vector4T< T > &v)
 Assignment operator that truncates a V4 to a V2. More...
 
constexpr SYS_FORCE_INLINE
UT_Vector2T
operator= (const T a) noexcept
 
SYS_FORCE_INLINE UT_Vector2T< Toperator- () const
 
void multiplyComponents (const UT_Vector2T< T > &v)
 
T whichSide (const UT_Vector2T< T > &e1, const UT_Vector2T< T > &e2) const
 
template<typename S >
UT_Vector2T< T > & operator*= (const UT_Matrix2T< S > &mat)
 
constexpr SYS_FORCE_INLINE T dot (const UT_Vector2T &b) const noexcept
 
UT_Vector2T< Tproject (const UT_Vector2T< T > &u) const
 Calculates the orthogonal projection of a vector u on the *this vector. More...
 
UT_Vector2T< Tprojection (const UT_Vector2T< T > &p, const UT_Vector2T< T > &v) const
 
UT_Vector3T< TgetBary (const UT_Vector2T< T > &t0, const UT_Vector2T< T > &t1, const UT_Vector2T< T > &t2, bool *degen=NULL) const
 
unsigned hash () const
 Compute a hash. More...
 
void assign (T xx=0.0f, T yy=0.0f)
 Set the values of the vector components. More...
 
void assign (const T *v)
 Set the values of the vector components. More...
 
int findMinAbsAxis () const
 These allow you to find out what indices to use for different axes. More...
 
int findMaxAbsAxis () const
 These allow you to find out what indices to use for different axes. More...
 
Tx ()
 
constexpr T x () const noexcept
 
Ty ()
 
constexpr T y () const noexcept
 
Toperator() (unsigned i)
 
T operator() (unsigned i) const
 
void homogenize ()
 Express the point in homogeneous coordinates or vice-versa. More...
 
void dehomogenize ()
 Express the point in homogeneous coordinates or vice-versa. More...
 
void save (std::ostream &os, int binary=0) const
 Protected I/O methods. More...
 
bool load (UT_IStream &is)
 Protected I/O methods. More...
 
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. More...
 

Public Attributes

T vec [tuple_size]
 

Static Public Attributes

static constexpr int tuple_size = 2
 

Friends

constexpr bool isZero (const UT_Vector2T &a) noexcept
 
constexpr T length2 (const UT_Vector2T &a) noexcept
 
constexpr T distance2 (const UT_Vector2T &a, const UT_Vector2T &b) noexcept
 
constexpr bool operator== (const UT_Vector2T &a, const UT_Vector2T &b) noexcept
 
constexpr bool operator!= (const UT_Vector2T &a, const UT_Vector2T &b) noexcept
 
constexpr bool operator< (const UT_Vector2T &a, const UT_Vector2T &b) noexcept
 
constexpr bool operator<= (const UT_Vector2T &a, const UT_Vector2T &b) noexcept
 
constexpr bool operator> (const UT_Vector2T &a, const UT_Vector2T &b) noexcept
 
constexpr bool operator>= (const UT_Vector2T &a, const UT_Vector2T &b) noexcept
 
std::ostream & operator<< (std::ostream &os, const UT_Vector2T< T > &v)
 I/O friends. More...
 

Detailed Description

template<typename T>
class UT_Vector2T< T >

2D Vector class.

Definition at line 157 of file UT_Vector2.h.

Member Typedef Documentation

template<typename T>
typedef T UT_Vector2T< T >::value_type

Definition at line 160 of file UT_Vector2.h.

Constructor & Destructor Documentation

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( )
default

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

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( const UT_Vector2T< T > &  that)
default
template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( UT_Vector2T< T > &&  that)
default
template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( const T  vx,
const T  vy 
)
inlinenoexcept

Definition at line 170 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( T  v)
inlineexplicitnoexcept

Definition at line 174 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( const fpreal16  v[])
inlineexplicitnoexcept

Definition at line 178 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( const fpreal32  v[])
inlineexplicitnoexcept

Definition at line 181 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( const fpreal64  v[])
inlineexplicitnoexcept

Definition at line 184 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( const int32  v[])
inlineexplicitnoexcept

Definition at line 187 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( const int64  v[])
inlineexplicitnoexcept

Definition at line 190 of file UT_Vector2.h.

template<typename T>
constexpr UT_Vector2T< T >::UT_Vector2T ( const UT_Vector3T< T > &  v)
inlinenoexcept

Definition at line 194 of file UT_Vector2.h.

template<typename T>
constexpr UT_Vector2T< T >::UT_Vector2T ( const UT_Vector4T< T > &  v)
inlinenoexcept

Definition at line 198 of file UT_Vector2.h.

template<typename T>
template<typename S >
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( const UT_Vector2T< S > &  v)
inlinenoexcept

Our own type of any given value_type.

Definition at line 204 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T >::UT_Vector2T ( const UT_FixedVector< T, tuple_size > &  v)
inlineexplicitnoexcept

UT_FixedVector of the same size.

Definition at line 209 of file UT_Vector2.h.

Member Function Documentation

template<typename T>
void UT_Vector2T< T >::assign ( T  xx = 0.0f,
T  yy = 0.0f 
)
inline

Set the values of the vector components.

Definition at line 448 of file UT_Vector2.h.

template<typename T>
void UT_Vector2T< T >::assign ( const T v)
inline

Set the values of the vector components.

Definition at line 453 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE const T* UT_Vector2T< T >::data ( ) const
inlinenoexcept

Definition at line 220 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE T* UT_Vector2T< T >::data ( )
inlinenoexcept

Definition at line 225 of file UT_Vector2.h.

template<typename T>
void UT_Vector2T< T >::dehomogenize ( )
inline

Express the point in homogeneous coordinates or vice-versa.

Definition at line 458 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE T UT_Vector2T< T >::distance ( const UT_Vector2T< T > &  b) const
inlinenoexcept

Definition at line 307 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE T UT_Vector2T< T >::distance2 ( const UT_Vector2T< T > &  b) const
inlinenoexcept

Definition at line 302 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE T UT_Vector2T< T >::dot ( const UT_Vector2T< T > &  b) const
inlinenoexcept

Definition at line 402 of file UT_Vector2.h.

template<typename T>
static int UT_Vector2T< T >::entries ( )
inlinestatic

Returns the vector size.

Definition at line 476 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE bool UT_Vector2T< T >::equalZero ( const T  tolerance = SYS_FTOLERANCE) const
inlinenoexcept

Definition at line 334 of file UT_Vector2.h.

template<typename T>
int UT_Vector2T< T >::findMaxAbsAxis ( ) const
inline

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

Definition at line 393 of file UT_Vector2.h.

template<typename T>
int UT_Vector2T< T >::findMinAbsAxis ( ) const
inline

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

Definition at line 386 of file UT_Vector2.h.

template<typename T>
UT_Vector3T<T> UT_Vector2T< T >::getBary ( const UT_Vector2T< T > &  t0,
const UT_Vector2T< T > &  t1,
const UT_Vector2T< T > &  t2,
bool *  degen = NULL 
) const

Compute (homogeneous) barycentric co-ordinates of this point relative to the triangle defined by t0, t1 and t2. (The point is projected into the triangle's plane.)

template<typename T>
unsigned UT_Vector2T< T >::hash ( void  ) const
inline

Compute a hash.

Definition at line 443 of file UT_Vector2.h.

template<typename T>
void UT_Vector2T< T >::homogenize ( )
inline

Express the point in homogeneous coordinates or vice-versa.

Definition at line 457 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE bool UT_Vector2T< T >::isEqual ( const UT_Vector2T< T > &  b,
const T  tolerance = SYS_FTOLERANCE 
) const
inlinenoexcept

Definition at line 339 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE bool UT_Vector2T< T >::isFinite ( ) const
inlinenoexcept

Definition at line 324 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE bool UT_Vector2T< T >::isNan ( ) const
inlinenoexcept

Definition at line 319 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE bool UT_Vector2T< T >::isZero ( ) const
inlinenoexcept

Definition at line 329 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE T UT_Vector2T< T >::length ( void  ) const
inlinenoexcept

Definition at line 297 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE T UT_Vector2T< T >::length2 ( ) const
inlinenoexcept

Definition at line 292 of file UT_Vector2.h.

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

Protected I/O methods.

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

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

template<typename T>
constexpr SYS_FORCE_INLINE T UT_Vector2T< T >::maxComponent ( ) const
inlinenoexcept

Definition at line 344 of file UT_Vector2.h.

template<typename T>
void UT_Vector2T< T >::multiplyComponents ( const UT_Vector2T< T > &  v)
inline

Definition at line 363 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE void UT_Vector2T< T >::negate ( )
inlinenoexcept

Definition at line 287 of file UT_Vector2.h.

template<typename T>
SYS_FORCE_INLINE UT_StorageMathFloat_t< T > UT_Vector2T< T >::normalize ( )
inlinenoexcept

Definition at line 312 of file UT_Vector2.h.

template<typename T>
T& UT_Vector2T< T >::operator() ( unsigned  i)
inline

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

Definition at line 430 of file UT_Vector2.h.

template<typename T>
T UT_Vector2T< T >::operator() ( unsigned  i) const
inline

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

Definition at line 435 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T& UT_Vector2T< T >::operator*= ( const T a)
inlinenoexcept

Definition at line 268 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T& UT_Vector2T< T >::operator*= ( const UT_Vector2T< T > &  a)
inlinenoexcept

Definition at line 281 of file UT_Vector2.h.

template<typename T>
template<typename S >
UT_Vector2T<T>& UT_Vector2T< T >::operator*= ( const UT_Matrix2T< S > &  mat)
inline

Definition at line 381 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T& UT_Vector2T< T >::operator+= ( const UT_Vector2T< T > &  a)
inlinenoexcept

Definition at line 244 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T& UT_Vector2T< T >::operator+= ( const T a)
inlinenoexcept

Definition at line 256 of file UT_Vector2.h.

template<typename T>
SYS_FORCE_INLINE UT_Vector2T<T> UT_Vector2T< T >::operator- ( ) const
inline

Definition at line 359 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T& UT_Vector2T< T >::operator-= ( const UT_Vector2T< T > &  a)
inlinenoexcept

Definition at line 250 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T& UT_Vector2T< T >::operator-= ( const T a)
inlinenoexcept

Definition at line 262 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T& UT_Vector2T< T >::operator/= ( const T a)
inlinenoexcept

Definition at line 274 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T<T>& UT_Vector2T< T >::operator= ( const UT_Vector2T< T > &  that)
default
template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T<T>& UT_Vector2T< T >::operator= ( UT_Vector2T< T > &&  that)
default
template<typename T>
template<typename S >
constexpr SYS_FORCE_INLINE UT_Vector2T<T>& UT_Vector2T< T >::operator= ( const UT_Vector2T< S > &  v)
inline

Definition at line 217 of file UT_Vector2.h.

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

Assignment operator that truncates a V3 to a V2.

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

Assignment operator that truncates a V4 to a V2.

template<typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T< T > & UT_Vector2T< T >::operator= ( const T  a)
noexcept

Definition at line 541 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE const T& UT_Vector2T< T >::operator[] ( exint  i) const
inlinenoexcept

Definition at line 230 of file UT_Vector2.h.

template<typename T>
constexpr SYS_FORCE_INLINE T& UT_Vector2T< T >::operator[] ( exint  i)
inlinenoexcept

Definition at line 237 of file UT_Vector2.h.

template<typename T>
UT_Vector2T<T> UT_Vector2T< T >::project ( const UT_Vector2T< T > &  u) const

Calculates the orthogonal projection of a vector u on the *this vector.

template<typename T>
UT_Vector2T<T> UT_Vector2T< T >::projection ( const UT_Vector2T< T > &  p,
const UT_Vector2T< T > &  v 
) const

Vector p (representing a point in 2-space) and vector v define a line. This member returns the projection of "this" onto the line (the point on the line that is closest to this point).

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

Protected I/O methods.

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

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

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

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

template<typename T>
T UT_Vector2T< T >::whichSide ( const UT_Vector2T< T > &  e1,
const UT_Vector2T< T > &  e2 
) const
inline

Given an oriented line from e1 passing through e2, determine on which side of the line the point p lies. Alternatively, determine in which half plane, positive or negative, the point lies. If the segment degenerates to a point, then the point is always on it.

Definition at line 374 of file UT_Vector2.h.

template<typename T>
T& UT_Vector2T< T >::x ( )
inline

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

Definition at line 426 of file UT_Vector2.h.

template<typename T>
constexpr T UT_Vector2T< T >::x ( ) const
inlinenoexcept

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

Definition at line 427 of file UT_Vector2.h.

template<typename T>
T& UT_Vector2T< T >::y ( )
inline

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

Definition at line 428 of file UT_Vector2.h.

template<typename T>
constexpr T UT_Vector2T< T >::y ( ) const
inlinenoexcept

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

Definition at line 429 of file UT_Vector2.h.

Friends And Related Function Documentation

template<typename T>
constexpr T distance2 ( const UT_Vector2T< T > &  a,
const UT_Vector2T< T > &  b 
)
friend

Definition at line 492 of file UT_Vector2.h.

template<typename T>
constexpr bool isZero ( const UT_Vector2T< T > &  a)
friend

Definition at line 482 of file UT_Vector2.h.

template<typename T>
constexpr T length2 ( const UT_Vector2T< T > &  a)
friend

Definition at line 487 of file UT_Vector2.h.

template<typename T>
constexpr bool operator!= ( const UT_Vector2T< T > &  a,
const UT_Vector2T< T > &  b 
)
friend

Definition at line 502 of file UT_Vector2.h.

template<typename T>
constexpr bool operator< ( const UT_Vector2T< T > &  a,
const UT_Vector2T< T > &  b 
)
friend

Lexicographic order comparison operators

Definition at line 509 of file UT_Vector2.h.

template<typename T>
std::ostream& operator<< ( std::ostream &  os,
const UT_Vector2T< T > &  v 
)
friend

I/O friends.

Definition at line 532 of file UT_Vector2.h.

template<typename T>
constexpr bool operator<= ( const UT_Vector2T< T > &  a,
const UT_Vector2T< T > &  b 
)
friend

Lexicographic order comparison operators

Definition at line 514 of file UT_Vector2.h.

template<typename T>
constexpr bool operator== ( const UT_Vector2T< T > &  a,
const UT_Vector2T< T > &  b 
)
friend

Definition at line 497 of file UT_Vector2.h.

template<typename T>
constexpr bool operator> ( const UT_Vector2T< T > &  a,
const UT_Vector2T< T > &  b 
)
friend

Lexicographic order comparison operators

Definition at line 519 of file UT_Vector2.h.

template<typename T>
constexpr bool operator>= ( const UT_Vector2T< T > &  a,
const UT_Vector2T< T > &  b 
)
friend

Lexicographic order comparison operators

Definition at line 524 of file UT_Vector2.h.

Member Data Documentation

template<typename T>
constexpr int UT_Vector2T< T >::tuple_size = 2
static

Definition at line 161 of file UT_Vector2.h.

template<typename T>
T UT_Vector2T< T >::vec[tuple_size]

Definition at line 478 of file UT_Vector2.h.


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