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

#include <UT_Matrix2.h>

Public Types

typedef T value_type
 

Public Member Functions

SYS_FORCE_INLINE UT_Matrix2T ()=default
 Construct uninitialized matrix. More...
 
constexpr UT_Matrix2T (const UT_Matrix2T &)=default
 Default copy constructor. More...
 
constexpr UT_Matrix2T (UT_Matrix2T &&)=default
 Default move constructor. More...
 
constexpr UT_Matrix2T (T val) noexcept
 Construct identity matrix, multipled by scalar. More...
 
 T (0)
 
UT_Matrix2T< T > & operator= (UT_Matrix2T< T > &&m)=default
 Default move assignment operator. More...
 
template<typename S >
UT_Matrix2T< T > & operator= (const UT_Matrix3T< S > &m)
 
UT_Matrix2T< Toperator- () const
 
UT_Matrix2T< T > & operator+= (const UT_Matrix2T< T > &m)
 
UT_Matrix2T< T > & operator-= (const UT_Matrix2T< T > &m)
 
UT_Matrix2T< T > & operator*= (const UT_Matrix2T< T > &m)
 
constexpr bool operator== (const UT_Matrix2T< T > &m) const noexcept
 
constexpr bool operator!= (const UT_Matrix2T< T > &m) const noexcept
 
UT_Matrix2T< T > & operator= (T val)
 
UT_Matrix2T< T > & operator+= (T scalar)
 
UT_Matrix2T< T > & operator-= (T scalar)
 
UT_Matrix2T< T > & operator*= (T scalar)
 
UT_Matrix2T< T > & operator/= (T scalar)
 
template<typename S >
UT_Matrix2T< T > & operator= (const UT_Vector2T< S > &vec)
 
template<typename S >
UT_Matrix2T< T > & operator+= (const UT_Vector2T< S > &vec)
 
template<typename S >
UT_Matrix2T< T > & operator-= (const UT_Vector2T< S > &vec)
 
constexpr T determinant () const noexcept
 
constexpr T trace () const noexcept
 
template<typename S >
int eigenvalues (UT_Vector2T< S > &r, UT_Vector2T< S > &i) const
 Returns eigenvalues of this matrix. More...
 
int invert ()
 Invert this matrix and return 0 if OK, 1 if singular. More...
 
int invert (UT_Matrix2T< T > &m) const
 
T tolerance () const
 Returns the tolerance of our class. More...
 
template<typename S >
int solve (const UT_Vector2T< S > &b, UT_Vector2T< S > &x) const
 
void transpose (void)
 
UT_Matrix2T< Ttranspose (void) const
 
bool isEqual (const UT_Matrix2T< T > &m, T tolerance=T(SYS_FTOLERANCE)) const
 
template<typename S >
void outerproductUpdate (T b, const UT_Vector2T< S > &v1, const UT_Vector2T< S > &v2)
 
void identity ()
 Set the matrix to identity. More...
 
void zero ()
 Set the matrix to zero. More...
 
bool isIdentity () const
 
bool isZero () const
 
void rotate (T theta)
 Rotate by theta radians. More...
 
void initialize ()
 Initialize this matrix to zero. More...
 
unsigned hash () const
 Compute a hash. More...
 
T getEuclideanNorm () const
 
T getEuclideanNorm2 () const
 Euclidean norm squared. More...
 
int save (std::ostream &os, int binary) const
 
bool load (UT_IStream &is)
 
void outAsciiNoName (std::ostream &os) const
 
template<>
int32 tolerance () const
 
template<>
int64 tolerance () const
 
constexpr UT_Matrix2T (const fpreal32 m[2][2]) noexcept
 
void scale (T sx, T sy)
 
void scale (const UT_Vector2T< T > &s)
 
SYS_FORCE_INLINE Toperator() (unsigned row, unsigned col) noexcept
 Return a matrix entry. No bounds checking on subscripts. More...
 
SYS_FORCE_INLINE T operator() (unsigned row, unsigned col) const noexcept
 Return a matrix entry. No bounds checking on subscripts. More...
 
const Tdata (void) const
 Return the raw matrix data. More...
 
Tdata (void)
 Return the raw matrix data. More...
 
Toperator() (unsigned row)
 Return a matrix row. No bounds checking on subscript. More...
 
const Toperator() (unsigned row) const
 Return a matrix row. No bounds checking on subscript. More...
 
const UT_Vector2T< T > & operator[] (unsigned row) const
 Return a matrix row. No bounds checking on subscript. More...
 
UT_Vector2T< T > & operator[] (unsigned row)
 Return a matrix row. No bounds checking on subscript. More...
 
bool save (UT_JSONWriter &w) const
 
bool save (UT_JSONValue &v) const
 
bool load (UT_JSONParser &p)
 

Static Public Member Functions

static UT_Matrix2T< TrotationMat (T theta)
 Create a rotation matrix for the given angle in radians. More...
 
static int entries ()
 Returns the vector size. More...
 

Public Attributes

 val
 
T matx [2][2]
 
T myFloats [tuple_size]
 

Static Public Attributes

static const int tuple_size = 4
 

Friends

std::ostream & operator<< (std::ostream &os, const UT_Matrix2T< T > &v)
 

Detailed Description

template<typename T>
class UT_Matrix2T< T >

This class implements a 2x2 matrix in row-major order.

Most of Houdini operates with row vectors that are left-multiplied with matrices. e.g., z = v * M

Definition at line 80 of file UT_Matrix2.h.

Member Typedef Documentation

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

Definition at line 84 of file UT_Matrix2.h.

Constructor & Destructor Documentation

template<typename T>
SYS_FORCE_INLINE UT_Matrix2T< T >::UT_Matrix2T ( )
default

Construct uninitialized matrix.

template<typename T>
constexpr UT_Matrix2T< T >::UT_Matrix2T ( const UT_Matrix2T< T > &  )
default

Default copy constructor.

template<typename T>
constexpr UT_Matrix2T< T >::UT_Matrix2T ( UT_Matrix2T< T > &&  )
default

Default move constructor.

template<typename T>
constexpr UT_Matrix2T< T >::UT_Matrix2T ( T  val)
inlineexplicitnoexcept

Construct identity matrix, multipled by scalar.

Definition at line 97 of file UT_Matrix2.h.

template<typename T>
constexpr UT_Matrix2T< T >::UT_Matrix2T ( const fpreal32  m[2][2])
inlineexplicitnoexcept

Construct a deep copy of the input row-major data.

Definition at line 104 of file UT_Matrix2.h.

Member Function Documentation

template<typename T>
const T* UT_Matrix2T< T >::data ( void  ) const
inline

Return the raw matrix data.

Definition at line 388 of file UT_Matrix2.h.

template<typename T>
T* UT_Matrix2T< T >::data ( void  )
inline

Return the raw matrix data.

Definition at line 389 of file UT_Matrix2.h.

template<typename T>
constexpr T UT_Matrix2T< T >::determinant ( ) const
inlinenoexcept

Definition at line 217 of file UT_Matrix2.h.

template<typename T>
template<typename S >
int UT_Matrix2T< T >::eigenvalues ( UT_Vector2T< S > &  r,
UT_Vector2T< S > &  i 
) const

Returns eigenvalues of this matrix.

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

Returns the vector size.

Definition at line 443 of file UT_Matrix2.h.

template<typename T>
T UT_Matrix2T< T >::getEuclideanNorm ( ) const
inline

Euclidean or Frobenius norm of a matrix. Does sqrt(sum(a_ij ^2))

Definition at line 415 of file UT_Matrix2.h.

template<typename T>
T UT_Matrix2T< T >::getEuclideanNorm2 ( ) const

Euclidean norm squared.

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

Compute a hash.

Definition at line 393 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::identity ( )
inline

Set the matrix to identity.

Definition at line 324 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::initialize ( void  )
inline

Initialize this matrix to zero.

Definition at line 366 of file UT_Matrix2.h.

template<typename T>
int UT_Matrix2T< T >::invert ( )
inline

Invert this matrix and return 0 if OK, 1 if singular.

Definition at line 229 of file UT_Matrix2.h.

template<typename T>
int UT_Matrix2T< T >::invert ( UT_Matrix2T< T > &  m) const
inline

Invert the matrix and return 0 if OK, 1 if singular. Puts the inverted matrix in m, and leaves this matrix unchanged.

Definition at line 238 of file UT_Matrix2.h.

template<typename T>
bool UT_Matrix2T< T >::isEqual ( const UT_Matrix2T< T > &  m,
T  tolerance = T(SYS_FTOLERANCE) 
) const
inline

Definition at line 298 of file UT_Matrix2.h.

template<typename T>
bool UT_Matrix2T< T >::isIdentity ( ) const
inline

Definition at line 332 of file UT_Matrix2.h.

template<typename T>
bool UT_Matrix2T< T >::isZero ( ) const
inline

Definition at line 339 of file UT_Matrix2.h.

template<typename T>
bool UT_Matrix2T< T >::load ( UT_IStream is)
template<typename T>
bool UT_Matrix2T< T >::load ( UT_JSONParser p)

Methods to serialize to a JSON stream. The matrix is stored as an array of 4 reals.

template<typename T>
constexpr bool UT_Matrix2T< T >::operator!= ( const UT_Matrix2T< T > &  m) const
inlinenoexcept

Definition at line 174 of file UT_Matrix2.h.

template<typename T>
SYS_FORCE_INLINE T& UT_Matrix2T< T >::operator() ( unsigned  row,
unsigned  col 
)
inlinenoexcept

Return a matrix entry. No bounds checking on subscripts.

Definition at line 374 of file UT_Matrix2.h.

template<typename T>
SYS_FORCE_INLINE T UT_Matrix2T< T >::operator() ( unsigned  row,
unsigned  col 
) const
inlinenoexcept

Return a matrix entry. No bounds checking on subscripts.

Definition at line 379 of file UT_Matrix2.h.

template<typename T>
T* UT_Matrix2T< T >::operator() ( unsigned  row)
inline

Return a matrix row. No bounds checking on subscript.

Definition at line 397 of file UT_Matrix2.h.

template<typename T>
const T* UT_Matrix2T< T >::operator() ( unsigned  row) const
inline

Return a matrix row. No bounds checking on subscript.

Definition at line 402 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator*= ( const UT_Matrix2T< T > &  m)
template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator*= ( T  scalar)
inline

Definition at line 195 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator+= ( const UT_Matrix2T< T > &  m)
inline

Definition at line 154 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator+= ( T  scalar)
inline

Definition at line 185 of file UT_Matrix2.h.

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

Definition at line 499 of file UT_Matrix2.h.

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

Definition at line 147 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator-= ( const UT_Matrix2T< T > &  m)
inline

Definition at line 160 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator-= ( T  scalar)
inline

Definition at line 191 of file UT_Matrix2.h.

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

Definition at line 509 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator/= ( T  scalar)
inline

Definition at line 201 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator= ( UT_Matrix2T< T > &&  m)
default

Default move assignment operator.

template<typename T>
template<typename S >
UT_Matrix2T<T>& UT_Matrix2T< T >::operator= ( const UT_Matrix3T< S > &  m)

Conversion operator that returns a 2x2 from a 3x3 matrix by ignoring the last row and last column.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator= ( T  val)
inline

Definition at line 179 of file UT_Matrix2.h.

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

Definition at line 489 of file UT_Matrix2.h.

template<typename T>
constexpr bool UT_Matrix2T< T >::operator== ( const UT_Matrix2T< T > &  m) const
inlinenoexcept

Definition at line 168 of file UT_Matrix2.h.

template<typename T >
const UT_Vector2T< T > & UT_Matrix2T< T >::operator[] ( unsigned  row) const
inline

Return a matrix row. No bounds checking on subscript.

Definition at line 518 of file UT_Matrix2.h.

template<typename T >
UT_Vector2T< T > & UT_Matrix2T< T >::operator[] ( unsigned  row)
inline

Return a matrix row. No bounds checking on subscript.

Definition at line 526 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::outAsciiNoName ( std::ostream &  os) const
template<typename T>
template<typename S >
void UT_Matrix2T< T >::outerproductUpdate ( T  b,
const UT_Vector2T< S > &  v1,
const UT_Vector2T< S > &  v2 
)
inline

Definition at line 311 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::rotate ( T  theta)
inline

Rotate by theta radians.

Definition at line 351 of file UT_Matrix2.h.

template<typename T>
static UT_Matrix2T<T> UT_Matrix2T< T >::rotationMat ( T  theta)
static

Create a rotation matrix for the given angle in radians.

template<typename T>
int UT_Matrix2T< T >::save ( std::ostream &  os,
int  binary 
) const
template<typename T>
bool UT_Matrix2T< T >::save ( UT_JSONWriter w) const

Methods to serialize to a JSON stream. The matrix is stored as an array of 4 reals.

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

Methods to serialize to a JSON stream. The matrix is stored as an array of 4 reals.

template<typename T>
void UT_Matrix2T< T >::scale ( T  sx,
T  sy 
)
inline

Multiply this matrix by a scale matrix with diagonal (sx, sy):

Definition at line 356 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::scale ( const UT_Vector2T< T > &  s)
inline

Multiply this matrix by a scale matrix with diagonal (sx, sy):

Definition at line 361 of file UT_Matrix2.h.

template<typename T>
template<typename S >
int UT_Matrix2T< T >::solve ( const UT_Vector2T< S > &  b,
UT_Vector2T< S > &  x 
) const
inline

Definition at line 268 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T< T >::T ( )
template<typename T>
T UT_Matrix2T< T >::tolerance ( ) const

Returns the tolerance of our class.

template<>
int32 UT_Matrix2T< int32 >::tolerance ( ) const
inline

Definition at line 474 of file UT_Matrix2.h.

template<>
int64 UT_Matrix2T< int64 >::tolerance ( ) const
inline

Definition at line 481 of file UT_Matrix2.h.

template<typename T>
constexpr T UT_Matrix2T< T >::trace ( ) const
inlinenoexcept

Definition at line 221 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::transpose ( void  )
inline

Definition at line 290 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T> UT_Matrix2T< T >::transpose ( void  ) const
template<typename T>
void UT_Matrix2T< T >::zero ( )
inline

Set the matrix to zero.

Definition at line 330 of file UT_Matrix2.h.

Friends And Related Function Documentation

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

Definition at line 435 of file UT_Matrix2.h.

Member Data Documentation

template<typename T>
T UT_Matrix2T< T >::matx[2][2]

Definition at line 450 of file UT_Matrix2.h.

template<typename T>
T UT_Matrix2T< T >::myFloats[tuple_size]

Definition at line 451 of file UT_Matrix2.h.

template<typename T>
const int UT_Matrix2T< T >::tuple_size = 4
static

Definition at line 85 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T< T >::val
Initial value:
{

Definition at line 99 of file UT_Matrix2.h.


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