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

#include <UT_Matrix4.h>

Classes

struct  FullTransformModel
 Define parameters for Houdini's full transform model. More...
 
struct  PivotSpaceT
 Define parameters for Houdini's pivot space. More...
 

Public Types

enum  applyType {
  BEFORE =1, EQUAL =2, AFTER =4, BEFORE_EQUAL =4,
  AFTER_EQUAL =6
}
 
typedef T value_type
 
typedef PivotSpaceT< TPivotSpace
 

Public Member Functions

SYS_FORCE_INLINE UT_Matrix4T ()=default
 Construct uninitialized matrix. More...
 
constexpr UT_Matrix4T (const UT_Matrix4T &)=default
 Default copy constructor. More...
 
constexpr UT_Matrix4T (UT_Matrix4T &&)=default
 Default move constructor. More...
 
constexpr UT_Matrix4T (fpreal64 val) noexcept
 Construct identity matrix, multipled by scalar. More...
 
UT_Matrix4T< T > & operator= (UT_Matrix4T< T > &&m)=default
 Default move assignment operator. More...
 
template<typename S >
UT_Matrix4T< T > & operator= (const UT_Matrix4T< S > &m)
 
template<typename S >
UT_Matrix4T< T > & operator= (const UT_SymMatrix4T< S > &m)
 Conversion from a symmetric to a non symmetric matrix. More...
 
UT_Matrix4T< Toperator- () const
 
UT_Matrix4T< T > & operator+= (const UT_Matrix4T< T > &m)
 
UT_Matrix4T< T > & operator-= (const UT_Matrix4T< T > &m)
 
template<typename S >
UT_Matrix4T< T > & operator*= (const UT_Matrix4T< S > &m)
 
template<typename S >
UT_Matrix4T< T > & operator*= (const UT_Matrix3T< S > &m)
 
bool operator== (const UT_Matrix4T< T > &m) const
 
bool operator!= (const UT_Matrix4T< T > &m) const
 
UT_Matrix4T< T > & operator= (fpreal64 v)
 
UT_Matrix4T< T > & operator*= (T scalar)
 
UT_Matrix4T< T > & operator/= (T scalar)
 
template<typename S >
UT_Matrix4T< T > & operator= (const UT_Vector4T< S > &vec)
 
template<typename S >
UT_Matrix4T< T > & operator+= (const UT_Vector4T< S > &vec)
 
template<typename S >
UT_Matrix4T< T > & operator-= (const UT_Vector4T< S > &vec)
 
T coFactor (int k, int l) const
 
T determinant () const
 
T determinant3 () const
 Compute determinant of the upper-left 3x3 sub-matrix. More...
 
T trace () const
 
int invertKramer (void)
 
int invertKramer (UT_Matrix4T< T > &m) const
 
template<typename S >
void instanceT (const UT_Vector3T< S > &p, const UT_Vector3T< S > &v, T s, const UT_Vector3T< S > *s3, const UT_Vector3T< S > *up, const UT_QuaternionT< S > *q, const UT_Vector3T< S > *tr, const UT_QuaternionT< S > *orient, const UT_Vector3T< S > *pivot)
 
void instance (const UT_Vector3F &p, const UT_Vector3F &v, T s, const UT_Vector3F *s3, const UT_Vector3F *up, const UT_QuaternionF *q, const UT_Vector3F *tr, const UT_QuaternionF *orient, const UT_Vector3F *pivot=NULL)
 
void instance (const UT_Vector3D &p, const UT_Vector3D &v, T s, const UT_Vector3D *s3, const UT_Vector3D *up, const UT_QuaternionD *q, const UT_Vector3D *tr, const UT_QuaternionD *orient, const UT_Vector3D *pivot=NULL)
 
template<typename S >
void instanceInverseT (const UT_Vector3T< S > &p, const UT_Vector3T< S > &v, T s, const UT_Vector3T< S > *s3, const UT_Vector3T< S > *up, const UT_QuaternionT< S > *q, const UT_Vector3T< S > *tr, const UT_QuaternionT< S > *orient, const UT_Vector3T< S > *pivot)
 
void instanceInverse (const UT_Vector3F &p, const UT_Vector3F &v, T s, const UT_Vector3F *s3, const UT_Vector3F *up, const UT_QuaternionF *q, const UT_Vector3F *tr, const UT_QuaternionF *orient, const UT_Vector3F *pivot=NULL)
 
void instanceInverse (const UT_Vector3D &p, const UT_Vector3D &v, T s, const UT_Vector3D *s3, const UT_Vector3D *up, const UT_QuaternionD *q, const UT_Vector3D *tr, const UT_QuaternionD *orient, const UT_Vector3D *pivot=NULL)
 
void transpose (void)
 
bool isEqual (const UT_Matrix4T< T > &m, T tolerance=T(SYS_FTOLERANCE)) const
 
template<typename S >
void changeSpace (UT_Vector3T< S > &iSrc, UT_Vector3T< S > &jSrc, UT_Vector3T< S > &iDest, UT_Vector3T< S > &jDest, int norm=1)
 
void xform (const UT_XformOrder &order, T tx=0.0f, T ty=0.0f, T tz=0.0f, T rx=0.0f, T ry=0.0f, T rz=0.0f, T sx=1.0f, T sy=1.0f, T sz=1.0f, T px=0.0f, T py=0.0f, T pz=0.0f, int reverse=0)
 
void xform (const UT_XformOrder &order, T tx, T ty, T tz, T rx, T ry, T rz, T sx, T sy, T sz, T s_xy, T s_xz, T s_yz, T px, T py, T pz, int reverse=0)
 
void xform (const UT_XformOrder &order, T tx, T ty, T tz, T rx, T ry, T rz, T sx, T sy, T sz, const PivotSpace &pivot, int reverse=0)
 
void xform (const UT_XformOrder &order, T tx, T ty, T tz, T rx, T ry, T rz, T sx, T sy, T sz, T s_xy, T s_xz, T s_yz, const PivotSpace &pivot, int reverse=0)
 
void xform (const FullTransformModel &parms, T min_abs_scale=T(0))
 
void xform (const UT_XformOrder &order, applyType type, char limit, T tx, T ty, T tz, T rx, T ry, T rz, T sx, T sy, T sz, T px, T py, T pz)
 
void rotate (const UT_XformOrder &order, applyType type, char limit, T rx, T ry, T rz)
 
template<typename S >
void getTranslates (UT_Vector3T< S > &translates) const
 
template<typename S >
void setTranslates (const UT_Vector3T< S > &translates)
 
template<typename S >
int explodeT (const UT_XformOrder &order, UT_Vector3T< S > &r, UT_Vector3T< S > &s, UT_Vector3T< S > &t, UT_Vector3T< S > *shears) const
 
int explode (const UT_XformOrder &order, UT_Vector3F &r, UT_Vector3F &s, UT_Vector3F &t, UT_Vector3F *shears=0) const
 
int explode (const UT_XformOrder &order, UT_Vector3D &r, UT_Vector3D &s, UT_Vector3D &t, UT_Vector3D *shears=0) const
 
template<typename S >
int explodeT (const UT_XformOrder &order, UT_Vector3T< S > &r, UT_Vector3T< S > &s, UT_Vector3T< S > &t, const UT_Vector3T< S > &p, UT_Vector3T< S > *shears) const
 
int explode (const UT_XformOrder &order, UT_Vector3F &r, UT_Vector3F &s, UT_Vector3F &t, const UT_Vector3F &p, UT_Vector3F *shears=0) const
 
int explode (const UT_XformOrder &order, UT_Vector3D &r, UT_Vector3D &s, UT_Vector3D &t, const UT_Vector3D &p, UT_Vector3D *shears=0) const
 
template<typename S >
int explodeT (const UT_XformOrder &order, UT_Vector3T< S > &r, UT_Vector3T< S > &s, UT_Vector3T< S > &t, const PivotSpaceT< S > &p, UT_Vector3T< S > *shears) const
 
int explode (const UT_XformOrder &order, UT_Vector3F &r, UT_Vector3F &s, UT_Vector3F &t, const PivotSpaceT< fpreal32 > &p, UT_Vector3F *shears=0) const
 
int explode (const UT_XformOrder &order, UT_Vector3D &r, UT_Vector3D &s, UT_Vector3D &t, const PivotSpaceT< fpreal64 > &p, UT_Vector3D *shears=0) const
 
template<typename S >
int explode2D (const UT_XformOrder &order, T &r, UT_Vector2T< S > &s, UT_Vector2T< S > &t, T *shears=0) const
 
template<typename S >
int explode2D (const UT_XformOrder &order, T &r, UT_Vector2T< S > &s, UT_Vector2T< S > &t, const UT_Vector2T< S > &p, T *shears=0) const
 
template<typename S >
void extractRotate (UT_Matrix3T< S > &dst) const
 
bool polarDecompose (UT_Matrix3T< T > *stretch=nullptr, bool reverse=true, const int max_iter=64, const T rel_tol=FLT_EPSILON)
 
bool makeRigidMatrix (UT_Matrix3T< T > *stretch=nullptr, bool reverse=true, const int max_iter=64, const T rel_tol=FLT_EPSILON)
 
template<typename S >
void stretch (UT_Vector3T< S > &v, T amount, int norm=1)
 
T dot (unsigned i, unsigned j) const
 
template<typename S >
void outerproductUpdate (T b, const UT_Vector4T< S > &v1, const UT_Vector4T< S > &v2)
 
void lerp (const UT_Matrix4T< T > &a, const UT_Matrix4T< T > &b, T t)
 
void identity ()
 Set the matrix to identity. More...
 
void zero ()
 Set the matrix to zero. More...
 
int isIdentity () const
 
int isZero () const
 
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 dump (const char *msg="") const
 
void outAsciiNoName (std::ostream &os) const
 
void perspective (fpreal zoom, fpreal image_aspect, fpreal pixel_aspect=1, fpreal clip_near=0, fpreal clip_far=1, fpreal window_xmin=0, fpreal window_xmax=1, fpreal window_ymin=0, fpreal window_ymax=1)
 
void orthographic (fpreal zoom, fpreal orthowidth, fpreal image_aspect, fpreal pixel_aspect=1, fpreal clip_near=0, fpreal clip_far=1, fpreal window_xmin=0, fpreal window_xmax=1, fpreal window_ymin=0, fpreal window_ymax=1)
 
template<typename S >
UT_Matrix4T< T > & operator= (const UT_Matrix3T< S > &m)
 
void leftMult (const UT_Matrix4T< T > &m)
 
void preMultiply (const UT_Matrix4T< T > &m)
 
int invert (T tol=0.0F)
 Invert this matrix and return 0 if OK, 1 if singular. More...
 
int invertDouble ()
 Invert this matrix and return 0 if OK, 1 if singular. More...
 
int invert (UT_Matrix4T< T > &m) const
 
int invertDouble (UT_Matrix4T< T > &m) const
 
template<typename S >
void rotate (UT_Vector3T< S > &axis, T theta, int norm=1)
 
void rotate (UT_Axis3::axis a, T theta)
 
template<typename S >
void prerotate (UT_Vector3T< S > &axis, T theta, int norm=1)
 
void prerotate (UT_Axis3::axis a, T theta)
 
void rotate (T rx, T ry, T rz, const UT_XformOrder &ord)
 
void rotate (const UT_Vector3T< T > &rad, const UT_XformOrder &ord)
 
void prerotate (T rx, T ry, T rz, const UT_XformOrder &ord)
 
void prerotate (const UT_Vector3T< T > &rad, const UT_XformOrder &ord)
 
void scale (T sx, T sy, T sz, T sw=1.0f)
 
SYS_FORCE_INLINE void scale (const UT_Vector3T< T > &s)
 
SYS_FORCE_INLINE void scale (T s)
 
void prescale (T sx, T sy, T sz, T sw=1.0f)
 
SYS_FORCE_INLINE void prescale (const UT_Vector3T< T > &s)
 
SYS_FORCE_INLINE void prescale (T s)
 
void shear (T s_xy, T s_xz, T s_yz)
 
void shear (const UT_Vector3T< T > &sh)
 
void translate (T dx, T dy, T dz=0.0f)
 
void translate (const UT_Vector3T< T > &delta)
 
void pretranslate (T dx, T dy, T dz=0.0f)
 
void pretranslate (const UT_Vector3T< T > &delta)
 
const Tdata (void) const
 Return the raw matrix data. More...
 
Tdata (void)
 Return the raw matrix data. More...
 
SYS_FORCE_INLINE Toperator() (unsigned row, unsigned col)
 Return a matrix entry. No bounds checking on subscripts. More...
 
SYS_FORCE_INLINE T operator() (unsigned row, unsigned col) const
 Return a matrix entry. No bounds checking on subscripts. More...
 
SYS_FORCE_INLINE Toperator() (unsigned row)
 Return a matrix row. No bounds checking on subscript. More...
 
SYS_FORCE_INLINE const Toperator() (unsigned row) const
 Return a matrix row. No bounds checking on subscript. More...
 
const UT_Vector4T< T > & operator[] (unsigned row) const
 Return a matrix row. No bounds checking on subscript. More...
 
UT_Vector4T< 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 const UT_Matrix4T< T > & getIdentityMatrix ()
 
static int entries ()
 Returns the vector size. More...
 
template<typename S >
static UT_Matrix4T< TrotationMat (UT_Vector3T< S > &axis, T theta, int norm=1)
 
static UT_Matrix4T< TrotationMat (UT_Axis3::axis a, T theta)
 

Public Attributes

union {
   T   matx [4][4]
 
   T   myFloats [tuple_size]
 
}; 
 

Static Public Attributes

static const int tuple_size = 16
 

Friends

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

Detailed Description

template<typename T>
class UT_Matrix4T< T >

This class implements a 4x4 fpreal matrix in row-major order.

Most of Houdini operates with row vectors that are left-multiplied with matrices. e.g., z = v * M As a result, translation data is in row 3 of the matrix, rather than column 3.

Examples:
GUI/GUI_PrimFramework.h.

Definition at line 85 of file UT_Matrix4.h.

Member Typedef Documentation

template<typename T>
typedef PivotSpaceT<T> UT_Matrix4T< T >::PivotSpace

Definition at line 695 of file UT_Matrix4.h.

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

Definition at line 89 of file UT_Matrix4.h.

Member Enumeration Documentation

template<typename T>
enum UT_Matrix4T::applyType
Enumerator
BEFORE 
EQUAL 
AFTER 
BEFORE_EQUAL 
AFTER_EQUAL 

Definition at line 763 of file UT_Matrix4.h.

Constructor & Destructor Documentation

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

Construct uninitialized matrix.

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

Default copy constructor.

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

Default move constructor.

template<typename T>
constexpr UT_Matrix4T< T >::UT_Matrix4T ( fpreal64  val)
inlineexplicitnoexcept

Construct identity matrix, multipled by scalar.

Definition at line 102 of file UT_Matrix4.h.

Member Function Documentation

template<typename T>
template<typename S >
void UT_Matrix4T< T >::changeSpace ( UT_Vector3T< S > &  iSrc,
UT_Vector3T< S > &  jSrc,
UT_Vector3T< S > &  iDest,
UT_Vector3T< S > &  jDest,
int  norm = 1 
)
template<typename T>
T UT_Matrix4T< T >::coFactor ( int  k,
int  l 
) const
inline

Definition at line 344 of file UT_Matrix4.h.

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

Return the raw matrix data.

Definition at line 959 of file UT_Matrix4.h.

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

Return the raw matrix data.

Definition at line 960 of file UT_Matrix4.h.

template<typename T>
T UT_Matrix4T< T >::determinant ( ) const
inline

Definition at line 369 of file UT_Matrix4.h.

template<typename T>
T UT_Matrix4T< T >::determinant3 ( ) const
inline

Compute determinant of the upper-left 3x3 sub-matrix.

Definition at line 377 of file UT_Matrix4.h.

template<typename T>
T UT_Matrix4T< T >::dot ( unsigned  i,
unsigned  j 
) const
inline

Definition at line 896 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::dump ( const char *  msg = "") const
template<typename T>
static int UT_Matrix4T< T >::entries ( void  )
inlinestatic

Returns the vector size.

Definition at line 1036 of file UT_Matrix4.h.

template<typename T>
int UT_Matrix4T< T >::explode ( const UT_XformOrder order,
UT_Vector3F r,
UT_Vector3F s,
UT_Vector3F t,
UT_Vector3F shears = 0 
) const
inline

Definition at line 791 of file UT_Matrix4.h.

template<typename T>
int UT_Matrix4T< T >::explode ( const UT_XformOrder order,
UT_Vector3D r,
UT_Vector3D s,
UT_Vector3D t,
UT_Vector3D shears = 0 
) const
inline

Definition at line 795 of file UT_Matrix4.h.

template<typename T>
int UT_Matrix4T< T >::explode ( const UT_XformOrder order,
UT_Vector3F r,
UT_Vector3F s,
UT_Vector3F t,
const UT_Vector3F p,
UT_Vector3F shears = 0 
) const
inline

Definition at line 806 of file UT_Matrix4.h.

template<typename T>
int UT_Matrix4T< T >::explode ( const UT_XformOrder order,
UT_Vector3D r,
UT_Vector3D s,
UT_Vector3D t,
const UT_Vector3D p,
UT_Vector3D shears = 0 
) const
inline

Definition at line 811 of file UT_Matrix4.h.

template<typename T>
int UT_Matrix4T< T >::explode ( const UT_XformOrder order,
UT_Vector3F r,
UT_Vector3F s,
UT_Vector3F t,
const PivotSpaceT< fpreal32 > &  p,
UT_Vector3F shears = 0 
) const
inline

Definition at line 823 of file UT_Matrix4.h.

template<typename T>
int UT_Matrix4T< T >::explode ( const UT_XformOrder order,
UT_Vector3D r,
UT_Vector3D s,
UT_Vector3D t,
const PivotSpaceT< fpreal64 > &  p,
UT_Vector3D shears = 0 
) const
inline

Definition at line 828 of file UT_Matrix4.h.

template<typename T>
template<typename S >
int UT_Matrix4T< T >::explode2D ( const UT_XformOrder order,
T r,
UT_Vector2T< S > &  s,
UT_Vector2T< S > &  t,
T shears = 0 
) const
template<typename T>
template<typename S >
int UT_Matrix4T< T >::explode2D ( const UT_XformOrder order,
T r,
UT_Vector2T< S > &  s,
UT_Vector2T< S > &  t,
const UT_Vector2T< S > &  p,
T shears = 0 
) const
template<typename T>
template<typename S >
int UT_Matrix4T< T >::explodeT ( const UT_XformOrder order,
UT_Vector3T< S > &  r,
UT_Vector3T< S > &  s,
UT_Vector3T< S > &  t,
UT_Vector3T< S > *  shears 
) const
template<typename T>
template<typename S >
int UT_Matrix4T< T >::explodeT ( const UT_XformOrder order,
UT_Vector3T< S > &  r,
UT_Vector3T< S > &  s,
UT_Vector3T< S > &  t,
const UT_Vector3T< S > &  p,
UT_Vector3T< S > *  shears 
) const
template<typename T>
template<typename S >
int UT_Matrix4T< T >::explodeT ( const UT_XformOrder order,
UT_Vector3T< S > &  r,
UT_Vector3T< S > &  s,
UT_Vector3T< S > &  t,
const PivotSpaceT< S > &  p,
UT_Vector3T< S > *  shears 
) const
template<typename T>
template<typename S >
void UT_Matrix4T< T >::extractRotate ( UT_Matrix3T< S > &  dst) const

WARNING: This may not produce good results! Instead, get the UT_Matrix3 part and call UT_Matrix3T::makeRotationMatrix().

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

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

Definition at line 1004 of file UT_Matrix4.h.

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

Euclidean norm squared.

template<typename T>
static const UT_Matrix4T<T>& UT_Matrix4T< T >::getIdentityMatrix ( )
static
template<typename T >
template<typename S >
void UT_Matrix4T< T >::getTranslates ( UT_Vector3T< S > &  translates) const
inline

Definition at line 1190 of file UT_Matrix4.h.

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

Compute a hash.

Definition at line 964 of file UT_Matrix4.h.

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

Set the matrix to identity.

Definition at line 924 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::instance ( const UT_Vector3F p,
const UT_Vector3F v,
T  s,
const UT_Vector3F s3,
const UT_Vector3F up,
const UT_QuaternionF q,
const UT_Vector3F tr,
const UT_QuaternionF orient,
const UT_Vector3F pivot = NULL 
)
inline

Definition at line 426 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::instance ( const UT_Vector3D p,
const UT_Vector3D v,
T  s,
const UT_Vector3D s3,
const UT_Vector3D up,
const UT_QuaternionD q,
const UT_Vector3D tr,
const UT_QuaternionD orient,
const UT_Vector3D pivot = NULL 
)
inline

Definition at line 432 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::instanceInverse ( const UT_Vector3F p,
const UT_Vector3F v,
T  s,
const UT_Vector3F s3,
const UT_Vector3F up,
const UT_QuaternionF q,
const UT_Vector3F tr,
const UT_QuaternionF orient,
const UT_Vector3F pivot = NULL 
)
inline

Definition at line 445 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::instanceInverse ( const UT_Vector3D p,
const UT_Vector3D v,
T  s,
const UT_Vector3D s3,
const UT_Vector3D up,
const UT_QuaternionD q,
const UT_Vector3D tr,
const UT_QuaternionD orient,
const UT_Vector3D pivot = NULL 
)
inline

Definition at line 451 of file UT_Matrix4.h.

template<typename T>
template<typename S >
void UT_Matrix4T< T >::instanceInverseT ( const UT_Vector3T< S > &  p,
const UT_Vector3T< S > &  v,
T  s,
const UT_Vector3T< S > *  s3,
const UT_Vector3T< S > *  up,
const UT_QuaternionT< S > *  q,
const UT_Vector3T< S > *  tr,
const UT_QuaternionT< S > *  orient,
const UT_Vector3T< S > *  pivot 
)
template<typename T>
template<typename S >
void UT_Matrix4T< T >::instanceT ( const UT_Vector3T< S > &  p,
const UT_Vector3T< S > &  v,
T  s,
const UT_Vector3T< S > *  s3,
const UT_Vector3T< S > *  up,
const UT_QuaternionT< S > *  q,
const UT_Vector3T< S > *  tr,
const UT_QuaternionT< S > *  orient,
const UT_Vector3T< S > *  pivot 
)
template<typename T>
int UT_Matrix4T< T >::invert ( T  tol = 0.0F)

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

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

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

template<typename T>
int UT_Matrix4T< T >::invertDouble ( )

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

template<typename T>
int UT_Matrix4T< T >::invertDouble ( UT_Matrix4T< T > &  m) const

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

template<typename T>
int UT_Matrix4T< T >::invertKramer ( void  )
template<typename T>
int UT_Matrix4T< T >::invertKramer ( UT_Matrix4T< T > &  m) const
template<typename T>
bool UT_Matrix4T< T >::isEqual ( const UT_Matrix4T< T > &  m,
T  tolerance = T(SYS_FTOLERANCE) 
) const
inline

Definition at line 471 of file UT_Matrix4.h.

template<typename T>
int UT_Matrix4T< T >::isIdentity ( ) const
inline

Definition at line 928 of file UT_Matrix4.h.

template<typename T>
int UT_Matrix4T< T >::isZero ( ) const
inline

Definition at line 942 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::leftMult ( const UT_Matrix4T< T > &  m)
inline

Multiply the passed-in matrix (on the left) by this (on the right) and assign the result to this. (operator*= does right-multiplication)

Definition at line 1311 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::lerp ( const UT_Matrix4T< T > &  a,
const UT_Matrix4T< T > &  b,
T  t 
)
inline

Definition at line 910 of file UT_Matrix4.h.

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

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

template<typename T>
bool UT_Matrix4T< T >::makeRigidMatrix ( UT_Matrix3T< T > *  stretch = nullptr,
bool  reverse = true,
const int  max_iter = 64,
const T  rel_tol = FLT_EPSILON 
)

Turn this matrix into the "closest" rigid transformation (only rotations and translations) matrix.

It uses polarDecompose and then negates the matrix if there is a negative determinant (scale). It returns false iff polarDecompose failed, possibly due to a singular matrix.

This is currently the one true way to turn an arbitrary matrix4 into a rotation and translation matrix. If that ever changes, put a warning here, and you may want to update UT_Matrix3::makeRotationMatrix too.

template<typename T>
bool UT_Matrix4T< T >::operator!= ( const UT_Matrix4T< T > &  m) const
inline

Definition at line 285 of file UT_Matrix4.h.

template<typename T>
SYS_FORCE_INLINE T& UT_Matrix4T< T >::operator() ( unsigned  row,
unsigned  col 
)
inline

Return a matrix entry. No bounds checking on subscripts.

Definition at line 969 of file UT_Matrix4.h.

template<typename T>
SYS_FORCE_INLINE T UT_Matrix4T< T >::operator() ( unsigned  row,
unsigned  col 
) const
inline

Return a matrix entry. No bounds checking on subscripts.

Definition at line 975 of file UT_Matrix4.h.

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

Return a matrix row. No bounds checking on subscript.

Definition at line 985 of file UT_Matrix4.h.

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

Return a matrix row. No bounds checking on subscript.

Definition at line 991 of file UT_Matrix4.h.

template<typename T >
template<typename S >
UT_Matrix4T< T > & UT_Matrix4T< T >::operator*= ( const UT_Matrix4T< S > &  m)
inline

Definition at line 1226 of file UT_Matrix4.h.

template<typename T >
template<typename S >
UT_Matrix4T< T > & UT_Matrix4T< T >::operator*= ( const UT_Matrix3T< S > &  m)
inline

Definition at line 1284 of file UT_Matrix4.h.

template<typename T>
UT_Matrix4T<T>& UT_Matrix4T< T >::operator*= ( T  scalar)
inline

NOTE: DO NOT use this for scaling the transform, since this scales the w column (3) as well, causing problems with translation later. Use M.scale(scalar) instead.

Definition at line 303 of file UT_Matrix4.h.

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

Definition at line 232 of file UT_Matrix4.h.

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

Definition at line 1162 of file UT_Matrix4.h.

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

Definition at line 223 of file UT_Matrix4.h.

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

Definition at line 247 of file UT_Matrix4.h.

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

Definition at line 1176 of file UT_Matrix4.h.

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

Definition at line 318 of file UT_Matrix4.h.

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

Default move assignment operator.

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

Conversion operator that expands a 3x3 into a 4x4 matrix by adding a row and column of zeroes, except the diagonal element which is 1.

Definition at line 183 of file UT_Matrix4.h.

template<typename T>
template<typename S >
UT_Matrix4T<T>& UT_Matrix4T< T >::operator= ( const UT_Matrix4T< S > &  m)
inline

Definition at line 197 of file UT_Matrix4.h.

template<typename T>
template<typename S >
UT_Matrix4T<T>& UT_Matrix4T< T >::operator= ( const UT_SymMatrix4T< S > &  m)
inline

Conversion from a symmetric to a non symmetric matrix.

Definition at line 212 of file UT_Matrix4.h.

template<typename T>
UT_Matrix4T<T>& UT_Matrix4T< T >::operator= ( fpreal64  v)
inline

Definition at line 291 of file UT_Matrix4.h.

template<typename T >
template<typename S >
UT_Matrix4T< T > & UT_Matrix4T< T >::operator= ( const UT_Vector4T< S > &  vec)
inline

Definition at line 1150 of file UT_Matrix4.h.

template<typename T>
bool UT_Matrix4T< T >::operator== ( const UT_Matrix4T< T > &  m) const
inline

Definition at line 269 of file UT_Matrix4.h.

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

Return a matrix row. No bounds checking on subscript.

Definition at line 1209 of file UT_Matrix4.h.

template<typename T >
UT_Vector4T< T > & UT_Matrix4T< T >::operator[] ( unsigned  row)
inline

Return a matrix row. No bounds checking on subscript.

Definition at line 1217 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::orthographic ( fpreal  zoom,
fpreal  orthowidth,
fpreal  image_aspect,
fpreal  pixel_aspect = 1,
fpreal  clip_near = 0,
fpreal  clip_far = 1,
fpreal  window_xmin = 0,
fpreal  window_xmax = 1,
fpreal  window_ymin = 0,
fpreal  window_ymax = 1 
)

Create an orthographic projection matrix with the given parameters. This can be used to project points onto the so-called NDC coordinates of a camera. For example, given a point P (in the space of a camera):

proj.orthographic(zoom, 1, image_aspect);
ndc = P * proj;
  • zoom
    The zoom for the lens
  • orthowidth
    An additional "zoom" factor
  • image_aspect
    The resolution of the image
  • pixel_aspect
    The pixel aspect (the aspect ratio of pixels)
  • near,far
    The near/far clipping planes
  • window
    The offset for the projection window.

The projection transform will transform the z coordinate of the camera space point such that the near coordinate will map to 0 and the far coordinate will map to 1. That is n dz.z = fit(P.z, near, far, 0, 1); . Thus, if the near/far are set to 0/1, the NDC z-coordinate will be the same as the camera space z. If the near/far are set to 0/-1, the Z coordinate will be negated.

Note
Sometimes the zoom is expressed in terms of focal and aperture. In this case: zoom = focal/aperture
Sometimes the image_aspect is expressed in terms of xrex and yres. In this case: image_aspect = xres / yres
To make a single transform from world space to NDC space given a camera matrix and a projection matrix, you would use worldToNDC = worldToCamera * projection;
template<typename T>
void UT_Matrix4T< T >::outAsciiNoName ( std::ostream &  os) const
template<typename T>
template<typename S >
void UT_Matrix4T< T >::outerproductUpdate ( T  b,
const UT_Vector4T< S > &  v1,
const UT_Vector4T< S > &  v2 
)
template<typename T>
void UT_Matrix4T< T >::perspective ( fpreal  zoom,
fpreal  image_aspect,
fpreal  pixel_aspect = 1,
fpreal  clip_near = 0,
fpreal  clip_far = 1,
fpreal  window_xmin = 0,
fpreal  window_xmax = 1,
fpreal  window_ymin = 0,
fpreal  window_ymax = 1 
)

Create a perspective projection matrix with the given parameters. This can be used to project points onto the so-called NDC coordinates of a camera. For example, given a point P (in the space of a camera):

proj.perspective(zoom, image_aspect);
ndc = P * proj;
  • zoom
    The zoom for the lens
  • image_aspect
    The aspect ratio of the image
  • pixel_aspect
    The pixel aspect (the aspect ratio of pixels)
  • near,far
    The near/far clipping planes
  • window
    The offset for the projection window.

The projection transform will transform the z coordinate of the camera space point such that the near coordinate will map to 0 and the far coordinate will map to 1. That is n dz.z = fit(P.z, near, far, 0, 1); . Thus, if the near/far are set to 0/1, the NDC z-coordinate will be the same as the camera space z. If the near/far are set to 0/-1, the Z coordinate will be negated.

Note
Sometimes the zoom is expressed in terms of focal and aperture. In this case: zoom = focal/aperture
Sometimes the image_aspect is expressed in terms of xres and yres. In this case: image_aspect = xres / yres
To make a single transform from world space to NDC space given a camera matrix and a projection matrix, you would use worldToNDC = worldToCamera * projection;
template<typename T>
bool UT_Matrix4T< T >::polarDecompose ( UT_Matrix3T< T > *  stretch = nullptr,
bool  reverse = true,
const int  max_iter = 64,
const T  rel_tol = FLT_EPSILON 
)

Perform the polar decomposition of the 3x3 matrix M into an orthogonal matrix Q and an symmetric positive-semidefinite matrix S. This is more useful than explode() or extractRotate() when the desire is to blend transforms. By default, it gives M=SQ, a left polar decomposition. If reverse is false, then it gives M=QS, a right polar decomposition.

This method is similar to the UT_Matrix3 version except it only operates on the upper-right 3x3 portion.

Precondition
The upper-right 3x3 portion of *this is non-singular
Postcondition
The upper-right 3x3 porition = Q, and if stretch != 0: *stretch = S.
Returns
True if successful
template<typename T>
void UT_Matrix4T< T >::preMultiply ( const UT_Matrix4T< T > &  m)
inline

Multiply the passed-in matrix (on the left) by this (on the right) and assign the result to this. (operator*= does right-multiplication)

Definition at line 338 of file UT_Matrix4.h.

template<typename T>
template<typename S >
void UT_Matrix4T< T >::prerotate ( UT_Vector3T< S > &  axis,
T  theta,
int  norm = 1 
)

Pre-multiply this matrix by a 3x3 rotation matrix determined by the axis and angle of rotation in radians. If 'norm' is not 0, the axis vector is normalized before computing the rotation matrix. rotationMat() returns a rotation matrix, and could as well be defined as a free floating function.

template<typename T>
void UT_Matrix4T< T >::prerotate ( UT_Axis3::axis  a,
T  theta 
)

Pre-multiply this matrix by a 3x3 rotation matrix determined by the axis and angle of rotation in radians. If 'norm' is not 0, the axis vector is normalized before computing the rotation matrix. rotationMat() returns a rotation matrix, and could as well be defined as a free floating function.

template<typename T>
void UT_Matrix4T< T >::prerotate ( T  rx,
T  ry,
T  rz,
const UT_XformOrder ord 
)

Pre-rotate by rx, ry, rz radians around the three basic axes in the order given by UT_XformOrder.

template<typename T>
void UT_Matrix4T< T >::prerotate ( const UT_Vector3T< T > &  rad,
const UT_XformOrder ord 
)
inline

Pre-rotate by rx, ry, rz radians around the three basic axes in the order given by UT_XformOrder.

Definition at line 538 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::prescale ( T  sx,
T  sy,
T  sz,
T  sw = 1.0f 
)
inline

Pre-multiply this matrix by a scale matrix with diagonal (sx, sy, sz)

Definition at line 566 of file UT_Matrix4.h.

template<typename T>
SYS_FORCE_INLINE void UT_Matrix4T< T >::prescale ( const UT_Vector3T< T > &  s)
inline

Pre-multiply this matrix by a scale matrix with diagonal (sx, sy, sz)

Definition at line 580 of file UT_Matrix4.h.

template<typename T>
SYS_FORCE_INLINE void UT_Matrix4T< T >::prescale ( T  s)
inline

Pre-multiply this matrix by a scale matrix with diagonal (sx, sy, sz)

Definition at line 582 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::pretranslate ( T  dx,
T  dy,
T  dz = 0.0f 
)
inline

Pre-multiply this matrix by the translation determined by dx, dy, dz.

Definition at line 626 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::pretranslate ( const UT_Vector3T< T > &  delta)
inline

Pre-multiply this matrix by the translation determined by dx, dy, dz.

Definition at line 633 of file UT_Matrix4.h.

template<typename T>
template<typename S >
void UT_Matrix4T< T >::rotate ( UT_Vector3T< S > &  axis,
T  theta,
int  norm = 1 
)

Post-multiply this matrix by a 3x3 rotation matrix determined by the axis and angle of rotation in radians. If 'norm' is not 0, the axis vector is normalized before computing the rotation matrix. rotationMat() returns a rotation matrix, and could as well be defined as a free floating function.

template<typename T>
void UT_Matrix4T< T >::rotate ( UT_Axis3::axis  a,
T  theta 
)

Post-multiply this matrix by a 3x3 rotation matrix determined by the axis and angle of rotation in radians. If 'norm' is not 0, the axis vector is normalized before computing the rotation matrix. rotationMat() returns a rotation matrix, and could as well be defined as a free floating function.

template<typename T>
void UT_Matrix4T< T >::rotate ( T  rx,
T  ry,
T  rz,
const UT_XformOrder ord 
)

Post-rotate by rx, ry, rz radians around the three basic axes in the order given by UT_XformOrder.

template<typename T>
void UT_Matrix4T< T >::rotate ( const UT_Vector3T< T > &  rad,
const UT_XformOrder ord 
)
inline

Post-rotate by rx, ry, rz radians around the three basic axes in the order given by UT_XformOrder.

Definition at line 529 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::rotate ( const UT_XformOrder order,
applyType  type,
char  limit,
T  rx,
T  ry,
T  rz 
)
template<typename T>
template<typename S >
static UT_Matrix4T<T> UT_Matrix4T< T >::rotationMat ( UT_Vector3T< S > &  axis,
T  theta,
int  norm = 1 
)
static

Create a rotation matrix for the given angle in radians around the axis

template<typename T>
static UT_Matrix4T<T> UT_Matrix4T< T >::rotationMat ( UT_Axis3::axis  a,
T  theta 
)
static

Create a rotation matrix for the given angle in radians around the axis

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

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

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

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

template<typename T>
void UT_Matrix4T< T >::scale ( T  sx,
T  sy,
T  sz,
T  sw = 1.0f 
)
inline

Post-multiply this matrix by a scale matrix with diagonal (sx, sy, sz)

Definition at line 544 of file UT_Matrix4.h.

template<typename T>
SYS_FORCE_INLINE void UT_Matrix4T< T >::scale ( const UT_Vector3T< T > &  s)
inline

Post-multiply this matrix by a scale matrix with diagonal (sx, sy, sz)

Definition at line 558 of file UT_Matrix4.h.

template<typename T>
SYS_FORCE_INLINE void UT_Matrix4T< T >::scale ( T  s)
inline

Post-multiply this matrix by a scale matrix with diagonal (sx, sy, sz)

Definition at line 560 of file UT_Matrix4.h.

template<typename T >
template<typename S >
void UT_Matrix4T< T >::setTranslates ( const UT_Vector3T< S > &  translates)
inline

Definition at line 1200 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::shear ( T  s_xy,
T  s_xz,
T  s_yz 
)
inline

Post-multiply this matrix by the shear matrix formed by (sxy, sxz, syz)

Definition at line 588 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::shear ( const UT_Vector3T< T > &  sh)
inline

Post-multiply this matrix by the shear matrix formed by (sxy, sxz, syz)

Definition at line 602 of file UT_Matrix4.h.

template<typename T>
template<typename S >
void UT_Matrix4T< T >::stretch ( UT_Vector3T< S > &  v,
T  amount,
int  norm = 1 
)
template<typename T>
T UT_Matrix4T< T >::trace ( ) const
inline

Definition at line 387 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::translate ( T  dx,
T  dy,
T  dz = 0.0f 
)
inline

Post-multiply this matrix by the translation determined by dx, dy, dz.

Definition at line 608 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::translate ( const UT_Vector3T< T > &  delta)
inline

Post-multiply this matrix by the translation determined by dx, dy, dz.

Definition at line 620 of file UT_Matrix4.h.

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

Definition at line 459 of file UT_Matrix4.h.

template<typename T>
void UT_Matrix4T< T >::xform ( const UT_XformOrder order,
T  tx = 0.0f,
T  ty = 0.0f,
T  tz = 0.0f,
T  rx = 0.0f,
T  ry = 0.0f,
T  rz = 0.0f,
T  sx = 1.0f,
T  sy = 1.0f,
T  sz = 1.0f,
T  px = 0.0f,
T  py = 0.0f,
T  pz = 0.0f,
int  reverse = 0 
)
template<typename T>
void UT_Matrix4T< T >::xform ( const UT_XformOrder order,
T  tx,
T  ty,
T  tz,
T  rx,
T  ry,
T  rz,
T  sx,
T  sy,
T  sz,
T  s_xy,
T  s_xz,
T  s_yz,
T  px,
T  py,
T  pz,
int  reverse = 0 
)
template<typename T>
void UT_Matrix4T< T >::xform ( const UT_XformOrder order,
T  tx,
T  ty,
T  tz,
T  rx,
T  ry,
T  rz,
T  sx,
T  sy,
T  sz,
const PivotSpace pivot,
int  reverse = 0 
)
template<typename T>
void UT_Matrix4T< T >::xform ( const UT_XformOrder order,
T  tx,
T  ty,
T  tz,
T  rx,
T  ry,
T  rz,
T  sx,
T  sy,
T  sz,
T  s_xy,
T  s_xz,
T  s_yz,
const PivotSpace pivot,
int  reverse = 0 
)
template<typename T>
void UT_Matrix4T< T >::xform ( const FullTransformModel parms,
T  min_abs_scale = T(0) 
)
template<typename T>
void UT_Matrix4T< T >::xform ( const UT_XformOrder order,
applyType  type,
char  limit,
T  tx,
T  ty,
T  tz,
T  rx,
T  ry,
T  rz,
T  sx,
T  sy,
T  sz,
T  px,
T  py,
T  pz 
)
template<typename T>
void UT_Matrix4T< T >::zero ( )
inline

Set the matrix to zero.

Definition at line 926 of file UT_Matrix4.h.

Friends And Related Function Documentation

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

Definition at line 1028 of file UT_Matrix4.h.

Member Data Documentation

union { ... }
template<typename T>
T UT_Matrix4T< T >::matx[4][4]

Definition at line 1041 of file UT_Matrix4.h.

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

Definition at line 1042 of file UT_Matrix4.h.

template<typename T>
const int UT_Matrix4T< T >::tuple_size = 16
static

Definition at line 90 of file UT_Matrix4.h.


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