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

#include <UT_Matrix3.h>

Public Types

typedef T value_type
 

Public Member Functions

SYS_FORCE_INLINE UT_Matrix3T ()=default
 Construct uninitialized matrix. More...
 
constexpr UT_Matrix3T (const UT_Matrix3T &)=default
 Default copy constructor. More...
 
constexpr UT_Matrix3T (UT_Matrix3T &&)=default
 Default move constructor. More...
 
constexpr UT_Matrix3T (fpreal64 val) noexcept
 Construct identity matrix, multipled by scalar. More...
 
bool INST SYS_FORCE_INLINE UT_Matrix3T (const UT_FixedVector< S, tuple_size, INST > &v) noexcept
 
bool INST SYS_FORCE_INLINE UT_Matrix3T (const UT_FixedVector< S, 3, INST > &r0, const UT_FixedVector< S, 3, INST > &r1, const UT_FixedVector< S, 3, INST > &r2) noexcept
 
 UT_Matrix3T (const UT_Matrix4T< fpreal64 > &m)
 
template<typename S >
 UT_Matrix3T (const UT_SymMatrix3T< S > m)
 Construct from a symmetric 3x3 matrix. More...
 
UT_Matrix3T< T > & operator= (const UT_Matrix3T< T > &m)=default
 Default copy assignment operator. More...
 
UT_Matrix3T< T > & operator= (UT_Matrix3T< T > &&m)=default
 Default move assignment operator. More...
 
template<typename S >
UT_Matrix3T< T > & operator= (const UT_Matrix3T< S > &m) noexcept
 
template<typename S >
UT_Matrix3T< T > & operator= (const UT_SymMatrix3T< S > &m)
 Convert from a symmetric matrix to non-symmetric. More...
 
UT_SymMatrix3T< TlowerTriangularSymMatrix3 () const
 Convert this to a symmetric matrix, using the lower-triangular portion. More...
 
UT_SymMatrix3T< TupperTriangularSymMatrix3 () const
 Convert this to a symmetric matrix, using the upper-triangular portion. More...
 
UT_SymMatrix3T< TaveragedSymMatrix3 () const
 Convert this to a symmetric matrix, using averaged components. More...
 
UT_Matrix3T< Toperator- () const
 
SYS_FORCE_INLINE void addScaledMat (T k, const UT_Matrix3T< T > &m)
 
SYS_FORCE_INLINE UT_Matrix3T< T > & operator+= (const UT_Matrix3T< T > &m)
 
SYS_FORCE_INLINE UT_Matrix3T< T > & operator-= (const UT_Matrix3T< T > &m)
 
UT_Matrix3T< T > & operator*= (const UT_Matrix3T< T > &m)
 
template<typename S >
UT_Matrix3T< T > & operator*= (const UT_SymMatrix3T< S > &m)
 Multiply given symmetric matrix on the right. More...
 
template<typename S >
void leftMult (const UT_SymMatrix3T< S > &m)
 Multiply given symmetric matrix on the left. More...
 
template<typename S >
void leftMult (const UT_Matrix3T< S > &m)
 Multiply given matrix3 on the left. More...
 
void multiply3 (const UT_Matrix4 &m)
 
void multiply3 (const UT_DMatrix4 &m)
 
constexpr bool operator== (const UT_Matrix3T< T > &m) const noexcept
 
constexpr bool operator!= (const UT_Matrix3T< T > &m) const noexcept
 
UT_Matrix3T< T > & operator= (T val)
 
SYS_FORCE_INLINE UT_Matrix3T< T > & operator*= (T scalar)
 
SYS_FORCE_INLINE UT_Matrix3T< T > & operator/= (T scalar)
 
template<typename S >
UT_Matrix3T< T > & operator= (const UT_Vector3T< S > &vec)
 
template<typename S >
UT_Matrix3T< T > & operator+= (const UT_Vector3T< S > &vec)
 
template<typename S >
UT_Matrix3T< T > & operator-= (const UT_Vector3T< S > &vec)
 
void getBasis ()
 
void arbitrary180rot ()
 
template<typename S >
void lookat (const UT_Vector3T< S > &from, const UT_Vector3T< S > &to, T roll=0)
 
template<typename S >
void lookat (const UT_Vector3T< S > &from, const UT_Vector3T< S > &to, const UT_Vector3T< S > &up)
 
template<typename S >
int orient (UT_Vector3T< S > &dir, UT_Vector3T< S > &up, int norm=1)
 
template<typename S >
int orientInverse (UT_Vector3T< S > &dir, UT_Vector3T< S > &up, int norm=1)
 
template<typename S >
void orientT (const UT_Vector3T< S > &v, T pscale, const UT_Vector3T< S > *s3, const UT_Vector3T< S > *up, const UT_QuaternionT< S > *q)
 
void orient (const UT_Vector3F &v, T pscale, const UT_Vector3F *s3, const UT_Vector3F *up, const UT_QuaternionF *q)
 
void orient (const UT_Vector3D &v, T pscale, const UT_Vector3D *s3, const UT_Vector3D *up, const UT_QuaternionD *q)
 
template<typename S >
void orientInverseT (const UT_Vector3T< S > &v, T pscale, const UT_Vector3T< S > *s3, const UT_Vector3T< S > *up, const UT_QuaternionT< S > *q)
 
void orientInverse (const UT_Vector3F &v, T pscale, const UT_Vector3F *s3, const UT_Vector3F *up, const UT_QuaternionF *q)
 
void orientInverse (const UT_Vector3D &v, T pscale, const UT_Vector3D *s3, const UT_Vector3D *up, const UT_QuaternionD *q)
 
SYS_FORCE_INLINE T coFactor (int k, int l) const
 
T determinant () const
 
T trace () const
 
template<typename S >
int eigenvalues (UT_Vector3T< S > &r, UT_Vector3T< S > &i) const
 
int invert ()
 Invert this matrix and return 0 if OK, 1 if singular. More...
 
int invert (UT_Matrix3T< T > &m) const
 
int invertKramer (UT_Matrix3T< T > &m, T abs_det_threshold=FLT_EPSILON) const
 
int invertKramer (T abs_det_threshold=FLT_EPSILON)
 
int safeInvertSymmetric (T tol=1e-6f)
 
bool diagonalizeSymmetric (UT_Matrix3T< T > &R, UT_Matrix3T< T > &D, T tol=1e-6f, int maxiter=100) const
 
void svdDecomposition (UT_Matrix3T< T > &U, UT_Matrix3T< T > &S, UT_Matrix3T< T > &V, T tol=1e-6f) const
 
void splitCovarianceToRotationScale (UT_Matrix3T< T > &R, UT_Matrix3T< T > &S, T tol=1e-6f) const
 
bool isSymmetric (T tolerance=T(SYS_FTOLERANCE)) const
 
void transpose (void)
 
UT_Matrix3T< TtransposedCopy () const
 
bool isEqual (const UT_Matrix3T< T > &m, T tolerance=T(SYS_FTOLERANCE)) const
 
SYS_FORCE_INLINE void negate ()
 Negates this matrix, i.e. multiplies it by -1. More...
 
template<typename S >
int crack (UT_Vector3T< S > &rvec, const UT_XformOrder &order, int remove_scales=1)
 
template<typename S >
int crack (UT_Vector3T< S > &rvec, const UT_XformOrder &order, int remove_scales=1) const
 
int crack2D (T &r) const
 
bool polarDecompose (UT_Matrix3T< T > *stretch=nullptr, bool reverse=true, const int max_iter=64, const T rel_tol=FLT_EPSILON)
 
bool makeRotationMatrix (UT_Matrix3T< T > *stretch=nullptr, bool reverse=true, const int max_iter=64, const T rel_tol=FLT_EPSILON)
 
template<typename S >
void extractScales2D (UT_Vector2T< S > &scales, T *shears=0)
 
void shearXY (T val)
 
void shearXZ (T val)
 
void shearYZ (T val)
 
template<typename S >
int solve (T cx, T cy, T cz, UT_Vector3T< S > &result) 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 rz=0.0f, T sx=1.0f, T sy=1.0f, T px=0.0f, T py=0.0f, int reverse=0)
 
void xform (const UT_XformOrder &order, T tx, T ty, T rz, T sx, T sy, T s_xy, T px, T py, int reverse=0)
 
template<typename S >
void stretch (UT_Vector3T< S > &v, T amount, int norm=1)
 
template<typename S >
UT_Matrix3T< Tstretch (UT_Vector3T< S > &v, T amount, int norm=1) const
 
int isNormalized () const
 
T dot (unsigned i, unsigned j) const
 
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...
 
T distanceSquared (const UT_Matrix3T< T > &src)
 
T getNorm1 () const
 
T getNormInf () const
 
int save (std::ostream &os, int binary) const
 
bool load (UT_IStream &is)
 
void outAsciiNoName (std::ostream &os) const
 
UT_Matrix3T< T > & operator= (const UT_Matrix4T< fpreal32 > &m)
 
UT_Matrix3T< T > & operator= (const UT_Matrix4T< fpreal64 > &m)
 
template<typename S >
void outerproductUpdateT (T b, const UT_Vector3T< S > &v1, const UT_Vector3T< S > &v2)
 
SYS_FORCE_INLINE void outerproductUpdate (T b, const UT_Vector3F &v1, const UT_Vector3F &v2)
 
SYS_FORCE_INLINE void outerproductUpdate (T b, const UT_Vector3D &v1, const UT_Vector3D &v2)
 
template<typename S >
void rotate (UT_Vector3T< S > &axis, T theta, int norm=1)
 
void rotate (UT_Axis3::axis a, T theta)
 
template<UT_Axis3::axis A>
void rotate (T theta)
 
template<typename S >
void prerotate (UT_Vector3T< S > &axis, T theta, int norm=1)
 
void prerotate (UT_Axis3::axis a, T theta)
 
template<UT_Axis3::axis A>
void prerotate (T theta)
 
void prerotate (T rx, T ry, T rz, const UT_XformOrder &order)
 
void prerotate (const UT_Vector3T< T > &rad, const UT_XformOrder &order)
 
void rotate (T rx, T ry, T rz, const UT_XformOrder &ord)
 
void rotate (const UT_Vector3T< T > &rad, const UT_XformOrder &ord)
 
void scale (T sx, T sy, T sz)
 
SYS_FORCE_INLINE void scale (const UT_Vector3T< T > &s)
 
void prescale (T sx, T sy, T sz)
 
SYS_FORCE_INLINE void prescale (const UT_Vector3T< T > &s)
 
void translate (T dx, T dy)
 
SYS_FORCE_INLINE void translate (const UT_Vector2T< T > &delta)
 
void pretranslate (T dx, T dy)
 
SYS_FORCE_INLINE void pretranslate (const UT_Vector2T< T > &delta)
 
template<typename S >
void conditionRotateT (UT_Vector3T< S > *scales)
 
void conditionRotate (UT_Vector3F *scales=0)
 
void conditionRotate (UT_Vector3D *scales)
 
template<typename S >
void extractScalesT (UT_Vector3T< S > &scales, UT_Vector3T< S > *shears)
 
void extractScales (UT_Vector3D &scales, UT_Vector3D *shears=0)
 
void extractScales (UT_Vector3F &scales, UT_Vector3F *shears=0)
 
void extractScales (UT_Vector3T< fpreal16 > &scales, UT_Vector3T< fpreal16 > *shears=0)
 
void shear (T s_xy, T s_xz, T s_yz)
 
SYS_FORCE_INLINE void shear (const UT_Vector3T< T > &sh)
 
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) 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...
 
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_Vector3T< T > & operator[] (unsigned row) const
 Return a matrix row. No bounds checking on subscript. More...
 
UT_Vector3T< 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_Matrix3T< T > & getIdentityMatrix ()
 
static int entries ()
 Returns the vector size. More...
 
template<typename S >
static UT_Matrix3T< TrotationMat (UT_Vector3T< S > &axis, T theta, int norm=1)
 
static UT_Matrix3T< TrotationMat (UT_Axis3::axis a, T theta)
 

Static Public Attributes

static const int tuple_size = 9
 

Friends

std::ostream & operator<< (std::ostream &os, const UT_Matrix3T< T > &v)
 
template<typename S >
int dihedral (UT_Vector3T< S > &a, UT_Vector3T< S > &b, int norm=1)
 
template<typename S >
static UT_Matrix3T< Tdihedral (UT_Vector3T< S > &a, UT_Vector3T< S > &b, UT_Vector3T< S > &c, int norm=1)
 

Detailed Description

template<typename T>
class UT_Matrix3T< T >

This class implements a 3x3 float matrix in row-major order.

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

This convention, combined with row-major order, is directly compatible with OpenGL matrix requirements.

Definition at line 83 of file UT_Matrix3.h.

Member Typedef Documentation

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

Definition at line 87 of file UT_Matrix3.h.

Constructor & Destructor Documentation

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

Construct uninitialized matrix.

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

Default copy constructor.

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

Default move constructor.

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

Construct identity matrix, multipled by scalar.

Definition at line 100 of file UT_Matrix3.h.

template<typename T>
bool INST SYS_FORCE_INLINE UT_Matrix3T< T >::UT_Matrix3T ( const UT_FixedVector< S, tuple_size, INST > &  v)
inlineexplicitnoexcept

Definition at line 118 of file UT_Matrix3.h.

template<typename T>
bool INST SYS_FORCE_INLINE UT_Matrix3T< T >::UT_Matrix3T ( const UT_FixedVector< S, 3, INST > &  r0,
const UT_FixedVector< S, 3, INST > &  r1,
const UT_FixedVector< S, 3, INST > &  r2 
)
inlinenoexcept

Definition at line 127 of file UT_Matrix3.h.

template<typename T>
UT_Matrix3T< T >::UT_Matrix3T ( const UT_Matrix4T< fpreal64 > &  m)
explicit
template<typename T>
template<typename S >
UT_Matrix3T< T >::UT_Matrix3T ( const UT_SymMatrix3T< S m)
inlineexplicit

Construct from a symmetric 3x3 matrix.

Definition at line 161 of file UT_Matrix3.h.

Member Function Documentation

template<typename T>
SYS_FORCE_INLINE void UT_Matrix3T< T >::addScaledMat ( T  k,
const UT_Matrix3T< T > &  m 
)
inline

Definition at line 235 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::arbitrary180rot ( )
template<typename T>
UT_SymMatrix3T<T> UT_Matrix3T< T >::averagedSymMatrix3 ( ) const
inline

Convert this to a symmetric matrix, using averaged components.

Definition at line 216 of file UT_Matrix3.h.

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

Definition at line 548 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::conditionRotate ( UT_Vector3F scales = 0)
inline

This method will condition the matrix so that it's a valid rotation matrix (i.e. crackable). Ideally, the scales should be removed first, but this method will attempt to do this as well. It will return the conditioned scales if a vector is passed in. WARNING: If you just want a rotation matrix, use makeRotationMatrix()!

Definition at line 831 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::conditionRotate ( UT_Vector3D scales)
inline

This method will condition the matrix so that it's a valid rotation matrix (i.e. crackable). Ideally, the scales should be removed first, but this method will attempt to do this as well. It will return the conditioned scales if a vector is passed in. WARNING: If you just want a rotation matrix, use makeRotationMatrix()!

Definition at line 833 of file UT_Matrix3.h.

template<typename T>
template<typename S >
void UT_Matrix3T< T >::conditionRotateT ( UT_Vector3T< S > *  scales)

This method will condition the matrix so that it's a valid rotation matrix (i.e. crackable). Ideally, the scales should be removed first, but this method will attempt to do this as well. It will return the conditioned scales if a vector is passed in. WARNING: If you just want a rotation matrix, use makeRotationMatrix()!

template<typename T>
template<typename S >
int UT_Matrix3T< T >::crack ( UT_Vector3T< S > &  rvec,
const UT_XformOrder order,
int  remove_scales = 1 
)

Generate the x, y, and z values of rotation in radians. Return 0 if successful, and a non-zero value otherwise: 1 if the matrix is not a valid rotation matrix, 2 if rotOrder is invalid, and 3 for other errors. rotOrder must be given as a UT_XformOrder permulation. WARNING: For animation or transform blending, use polarDecompose() or makeRotationMatrix()! WARNING: The non-const method changes the matrix!

template<typename T>
template<typename S >
int UT_Matrix3T< T >::crack ( UT_Vector3T< S > &  rvec,
const UT_XformOrder order,
int  remove_scales = 1 
) const
template<typename T>
int UT_Matrix3T< T >::crack2D ( T r) const
template<typename T>
const T* UT_Matrix3T< T >::data ( void  ) const
inline

Return the raw matrix data.

Definition at line 975 of file UT_Matrix3.h.

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

Return the raw matrix data.

Definition at line 976 of file UT_Matrix3.h.

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

Definition at line 562 of file UT_Matrix3.h.

template<typename T>
bool UT_Matrix3T< T >::diagonalizeSymmetric ( UT_Matrix3T< T > &  R,
UT_Matrix3T< T > &  D,
T  tol = 1e-6f,
int  maxiter = 100 
) const
template<typename T>
template<typename S >
static UT_Matrix3T<T> UT_Matrix3T< T >::dihedral ( UT_Vector3T< S > &  a,
UT_Vector3T< S > &  b,
UT_Vector3T< S > &  c,
int  norm = 1 
)
static

Compute the dihedral: return the matrix that computes the rotation around the axes normal to both a and b, (their cross product), by the angle which is between a and b. The resulting matrix maps a onto b. If a and b have the same direction, what comes out is the identity matrix. If a and b are opposed, the rotation is undefined and the method returns a vector c of zeroes (check with !c); if all is OK, c != 0. The transformation is a symmetry around vector a, then a symmetry around (norm(a) and norm(b)). If a or b needs to be normalized, pass a non-zero value in norm. The second function places the result in 'm', and returns 0 if a and b are not opposed; otherwise, it returns 1.

template<typename T>
template<typename S >
int UT_Matrix3T< T >::dihedral ( UT_Vector3T< S > &  a,
UT_Vector3T< S > &  b,
int  norm = 1 
)
Note
If dihedral() returns 0, this matrix is NOT modified!
template<typename T>
T UT_Matrix3T< T >::distanceSquared ( const UT_Matrix3T< T > &  src)

Get the squared Euclidean distance between '*this' and 'from' Returns sum_ij(sqr(b_ij-a_ij))

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

Definition at line 937 of file UT_Matrix3.h.

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

Computes the eigenvalues. Returns number of real eigenvalues found. Uses UT_RootFinder::cubic

Parameters
rThe real eigenvalues
iThe imaginary eigenvalues
template<typename T>
static int UT_Matrix3T< T >::entries ( void  )
inlinestatic

Returns the vector size.

Definition at line 1057 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::extractScales ( UT_Vector3D scales,
UT_Vector3D shears = 0 
)
inline

Extract scales and shears from the matrix leaving the matrix as a nice orthogonal rotation matrix. The shears are: XY, XZ, and YZ WARNING: If you just want a rotation matrix, use makeRotationMatrix()!

Definition at line 844 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::extractScales ( UT_Vector3F scales,
UT_Vector3F shears = 0 
)
inline

Extract scales and shears from the matrix leaving the matrix as a nice orthogonal rotation matrix. The shears are: XY, XZ, and YZ WARNING: If you just want a rotation matrix, use makeRotationMatrix()!

Definition at line 846 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::extractScales ( UT_Vector3T< fpreal16 > &  scales,
UT_Vector3T< fpreal16 > *  shears = 0 
)
inline

Extract scales and shears from the matrix leaving the matrix as a nice orthogonal rotation matrix. The shears are: XY, XZ, and YZ WARNING: If you just want a rotation matrix, use makeRotationMatrix()!

Definition at line 848 of file UT_Matrix3.h.

template<typename T>
template<typename S >
void UT_Matrix3T< T >::extractScales2D ( UT_Vector2T< S > &  scales,
T shears = 0 
)
template<typename T>
template<typename S >
void UT_Matrix3T< T >::extractScalesT ( UT_Vector3T< S > &  scales,
UT_Vector3T< S > *  shears 
)

Extract scales and shears from the matrix leaving the matrix as a nice orthogonal rotation matrix. The shears are: XY, XZ, and YZ WARNING: If you just want a rotation matrix, use makeRotationMatrix()!

template<typename T>
void UT_Matrix3T< T >::getBasis ( )
template<typename T>
T UT_Matrix3T< T >::getEuclideanNorm ( ) const
inline

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

Definition at line 1015 of file UT_Matrix3.h.

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

Euclidean norm squared.

template<typename T>
static const UT_Matrix3T<T>& UT_Matrix3T< T >::getIdentityMatrix ( )
static
template<typename T>
T UT_Matrix3T< T >::getNorm1 ( ) const

Get the 1-norm of this matrix, assuming a row vector convention. Returns the maximum absolute row sum. ie. max_i(sum_j(abs(a_ij)))

template<typename T>
T UT_Matrix3T< T >::getNormInf ( ) const

Get the inf-norm of this matrix, assuming a row vector convention. Returns the maximum absolute column sum. ie. max_j(sum_i(abs(a_ij)))

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

Compute a hash.

Definition at line 980 of file UT_Matrix3.h.

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

Set the matrix to identity.

Definition at line 945 of file UT_Matrix3.h.

template<typename T>
int UT_Matrix3T< T >::invert ( )

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

template<typename T>
int UT_Matrix3T< T >::invert ( UT_Matrix3T< 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_Matrix3T< T >::invertKramer ( UT_Matrix3T< T > &  m,
T  abs_det_threshold = FLT_EPSILON 
) const

Use Kramer's method to compute the matrix inverse If abs( det(m) ) <= abs_det_threshold, then return 1 without changing m Otherwise, return 0, storing the inverse matrix in m

NOTE: The default FLT_EPSILON is kept here to preserve existing behavior This is not a good default! The right threshold must be decided separately for each use case.

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

Definition at line 650 of file UT_Matrix3.h.

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

Definition at line 949 of file UT_Matrix3.h.

template<typename T>
int UT_Matrix3T< T >::isNormalized ( ) const
template<typename T>
bool UT_Matrix3T< T >::isSymmetric ( T  tolerance = T(SYS_FTOLERANCE)) const
template<typename T>
int UT_Matrix3T< T >::isZero ( ) const
inline

Definition at line 961 of file UT_Matrix3.h.

template<typename T>
template<typename S >
void UT_Matrix3T< T >::leftMult ( const UT_SymMatrix3T< S > &  m)
inline

Multiply given symmetric matrix on the left.

Definition at line 331 of file UT_Matrix3.h.

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

Multiply given matrix3 on the left.

Definition at line 356 of file UT_Matrix3.h.

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

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

template<typename T>
template<typename S >
void UT_Matrix3T< T >::lookat ( const UT_Vector3T< S > &  from,
const UT_Vector3T< S > &  to,
T  roll = 0 
)
template<typename T>
template<typename S >
void UT_Matrix3T< T >::lookat ( const UT_Vector3T< S > &  from,
const UT_Vector3T< S > &  to,
const UT_Vector3T< S > &  up 
)
template<typename T>
UT_SymMatrix3T<T> UT_Matrix3T< T >::lowerTriangularSymMatrix3 ( ) const
inline

Convert this to a symmetric matrix, using the lower-triangular portion.

Definition at line 200 of file UT_Matrix3.h.

template<typename T>
bool UT_Matrix3T< T >::makeRotationMatrix ( 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" rotation matrix.

It uses polarDecompose and then negates the matrix and stretch 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 matrix into a rotation matrix. If that ever changes, put a warning here, and you may want to update UT_Matrix4::makeRigidMatrix too.

template<typename T>
void UT_Matrix3T< T >::multiply3 ( const UT_Matrix4 m)
template<typename T>
void UT_Matrix3T< T >::multiply3 ( const UT_DMatrix4 m)
template<typename T>
SYS_FORCE_INLINE void UT_Matrix3T< T >::negate ( )
inline

Negates this matrix, i.e. multiplies it by -1.

Definition at line 742 of file UT_Matrix3.h.

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

Definition at line 386 of file UT_Matrix3.h.

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

Return a matrix entry. No bounds checking on subscripts.

Definition at line 984 of file UT_Matrix3.h.

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

Return a matrix entry. No bounds checking on subscripts.

Definition at line 990 of file UT_Matrix3.h.

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

Return a matrix row. No bounds checking on subscript.

Definition at line 999 of file UT_Matrix3.h.

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

Return a matrix row. No bounds checking on subscript.

Definition at line 1004 of file UT_Matrix3.h.

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

Definition at line 282 of file UT_Matrix3.h.

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

Multiply given symmetric matrix on the right.

Definition at line 304 of file UT_Matrix3.h.

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

Definition at line 400 of file UT_Matrix3.h.

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

Definition at line 250 of file UT_Matrix3.h.

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

Definition at line 1105 of file UT_Matrix3.h.

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

Definition at line 226 of file UT_Matrix3.h.

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

Definition at line 266 of file UT_Matrix3.h.

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

Definition at line 1117 of file UT_Matrix3.h.

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

Definition at line 408 of file UT_Matrix3.h.

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

Default copy assignment operator.

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

Default move assignment operator.

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

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

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

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

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

Definition at line 179 of file UT_Matrix3.h.

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

Convert from a symmetric matrix to non-symmetric.

Definition at line 189 of file UT_Matrix3.h.

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

Definition at line 392 of file UT_Matrix3.h.

template<typename T >
template<typename S >
UT_Matrix3T< T > & UT_Matrix3T< T >::operator= ( const UT_Vector3T< S > &  vec)
inline

Definition at line 1094 of file UT_Matrix3.h.

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

Definition at line 379 of file UT_Matrix3.h.

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

Return a matrix row. No bounds checking on subscript.

Definition at line 1231 of file UT_Matrix3.h.

template<typename T >
UT_Vector3T< T > & UT_Matrix3T< T >::operator[] ( unsigned  row)
inline

Return a matrix row. No bounds checking on subscript.

Definition at line 1239 of file UT_Matrix3.h.

template<typename T>
template<typename S >
int UT_Matrix3T< T >::orient ( UT_Vector3T< S > &  dir,
UT_Vector3T< S > &  up,
int  norm = 1 
)
template<typename T>
void UT_Matrix3T< T >::orient ( const UT_Vector3F v,
T  pscale,
const UT_Vector3F s3,
const UT_Vector3F up,
const UT_QuaternionF q 
)
inline

Definition at line 518 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::orient ( const UT_Vector3D v,
T  pscale,
const UT_Vector3D s3,
const UT_Vector3D up,
const UT_QuaternionD q 
)
inline

Definition at line 523 of file UT_Matrix3.h.

template<typename T>
template<typename S >
int UT_Matrix3T< T >::orientInverse ( UT_Vector3T< S > &  dir,
UT_Vector3T< S > &  up,
int  norm = 1 
)
template<typename T>
void UT_Matrix3T< T >::orientInverse ( const UT_Vector3F v,
T  pscale,
const UT_Vector3F s3,
const UT_Vector3F up,
const UT_QuaternionF q 
)
inline

Definition at line 533 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::orientInverse ( const UT_Vector3D v,
T  pscale,
const UT_Vector3D s3,
const UT_Vector3D up,
const UT_QuaternionD q 
)
inline

Definition at line 538 of file UT_Matrix3.h.

template<typename T>
template<typename S >
void UT_Matrix3T< T >::orientInverseT ( const UT_Vector3T< S > &  v,
T  pscale,
const UT_Vector3T< S > *  s3,
const UT_Vector3T< S > *  up,
const UT_QuaternionT< S > *  q 
)
template<typename T>
template<typename S >
void UT_Matrix3T< T >::orientT ( const UT_Vector3T< S > &  v,
T  pscale,
const UT_Vector3T< S > *  s3,
const UT_Vector3T< S > *  up,
const UT_QuaternionT< S > *  q 
)
template<typename T>
void UT_Matrix3T< T >::outAsciiNoName ( std::ostream &  os) const
template<typename T>
SYS_FORCE_INLINE void UT_Matrix3T< T >::outerproductUpdate ( T  b,
const UT_Vector3F v1,
const UT_Vector3F v2 
)
inline

Scaled outer product update (given scalar b, row vectors v1 and v2) this += b * transpose(v1) * v2

Definition at line 429 of file UT_Matrix3.h.

template<typename T>
SYS_FORCE_INLINE void UT_Matrix3T< T >::outerproductUpdate ( T  b,
const UT_Vector3D v1,
const UT_Vector3D v2 
)
inline

Scaled outer product update (given scalar b, row vectors v1 and v2) this += b * transpose(v1) * v2

Definition at line 434 of file UT_Matrix3.h.

template<typename T>
template<typename S >
void UT_Matrix3T< T >::outerproductUpdateT ( T  b,
const UT_Vector3T< S > &  v1,
const UT_Vector3T< S > &  v2 
)
inline

Scaled outer product update (given scalar b, row vectors v1 and v2) this += b * transpose(v1) * v2

Definition at line 1210 of file UT_Matrix3.h.

template<typename T>
bool UT_Matrix3T< 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 M into an orthogonal matrix Q and an symmetric positive-semidefinite matrix S. This is more useful than crack() or conditionRotate() 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.

Precondition
*this is non-singular
Postcondition
*this = Q, and if stretch != 0: *stretch = S
Returns
True if successful
template<typename T>
template<typename S >
void UT_Matrix3T< T >::prerotate ( UT_Vector3T< S > &  axis,
T  theta,
int  norm = 1 
)

Pre-multiply this matrix by the theta radians rotation around the axis

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

Pre-multiply this matrix by the theta radians rotation around the axis

template<typename T>
template<UT_Axis3::axis A>
void UT_Matrix3T< T >::prerotate ( T  theta)

Pre-multiply this matrix by the theta radians rotation around the axis

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

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

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

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

Definition at line 701 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::prescale ( T  sx,
T  sy,
T  sz 
)
inline

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

Definition at line 730 of file UT_Matrix3.h.

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

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

Definition at line 737 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::pretranslate ( T  dx,
T  dy 
)
inline

Pre-multiply this matrix by the translation matrix determined by (dx,dy)

Definition at line 767 of file UT_Matrix3.h.

template<typename T>
SYS_FORCE_INLINE void UT_Matrix3T< T >::pretranslate ( const UT_Vector2T< T > &  delta)
inline

Pre-multiply this matrix by the translation matrix determined by (dx,dy)

Definition at line 774 of file UT_Matrix3.h.

template<typename T>
template<typename S >
void UT_Matrix3T< 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_Matrix3T< 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>
template<UT_Axis3::axis A>
void UT_Matrix3T< T >::rotate ( 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_Matrix3T< 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_Matrix3T< 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 711 of file UT_Matrix3.h.

template<typename T>
template<typename S >
static UT_Matrix3T<T> UT_Matrix3T< 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_Matrix3T<T> UT_Matrix3T< 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_Matrix3T< T >::safeInvertSymmetric ( T  tol = 1e-6f)
template<typename T>
int UT_Matrix3T< T >::save ( std::ostream &  os,
int  binary 
) const
template<typename T>
bool UT_Matrix3T< T >::save ( UT_JSONWriter w) const

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

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

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

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

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

Definition at line 717 of file UT_Matrix3.h.

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

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

Definition at line 724 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< 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 868 of file UT_Matrix3.h.

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

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

Definition at line 880 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::shearXY ( T  val)
template<typename T>
void UT_Matrix3T< T >::shearXZ ( T  val)
template<typename T>
void UT_Matrix3T< T >::shearYZ ( T  val)
template<typename T>
template<typename S >
int UT_Matrix3T< T >::solve ( T  cx,
T  cy,
T  cz,
UT_Vector3T< S > &  result 
) const
template<typename T>
void UT_Matrix3T< T >::splitCovarianceToRotationScale ( UT_Matrix3T< T > &  R,
UT_Matrix3T< T > &  S,
T  tol = 1e-6f 
) const

Splits a covariance matrix into a scale & rotation component. This should be built by a series of outer product updates. R is the rotation component, S the inverse scale. If this is A, finds the inverse square root of AtA, S. We then set R = transpose(AS) to give us a rotation matrix. NOTE: For general matrices, use makeRotationMatrix()!

template<typename T>
template<typename S >
void UT_Matrix3T< T >::stretch ( UT_Vector3T< S > &  v,
T  amount,
int  norm = 1 
)
template<typename T>
template<typename S >
UT_Matrix3T<T> UT_Matrix3T< T >::stretch ( UT_Vector3T< S > &  v,
T  amount,
int  norm = 1 
) const
template<typename T>
void UT_Matrix3T< T >::svdDecomposition ( UT_Matrix3T< T > &  U,
UT_Matrix3T< T > &  S,
UT_Matrix3T< T > &  V,
T  tol = 1e-6f 
) const
template<typename T>
T UT_Matrix3T< T >::trace ( ) const
inline

Definition at line 568 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::translate ( T  dx,
T  dy 
)
inline

Post-multiply this matrix by a translation matrix determined by (dx,dy)

Definition at line 751 of file UT_Matrix3.h.

template<typename T>
SYS_FORCE_INLINE void UT_Matrix3T< T >::translate ( const UT_Vector2T< T > &  delta)
inline

Post-multiply this matrix by a translation matrix determined by (dx,dy)

Definition at line 761 of file UT_Matrix3.h.

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

Definition at line 635 of file UT_Matrix3.h.

template<typename T>
UT_Matrix3T<T> UT_Matrix3T< T >::transposedCopy ( ) const
inline

Definition at line 642 of file UT_Matrix3.h.

template<typename T>
UT_SymMatrix3T<T> UT_Matrix3T< T >::upperTriangularSymMatrix3 ( ) const
inline

Convert this to a symmetric matrix, using the upper-triangular portion.

Definition at line 208 of file UT_Matrix3.h.

template<typename T>
void UT_Matrix3T< T >::xform ( const UT_XformOrder order,
T  tx = 0.0f,
T  ty = 0.0f,
T  rz = 0.0f,
T  sx = 1.0f,
T  sy = 1.0f,
T  px = 0.0f,
T  py = 0.0f,
int  reverse = 0 
)
template<typename T>
void UT_Matrix3T< T >::xform ( const UT_XformOrder order,
T  tx,
T  ty,
T  rz,
T  sx,
T  sy,
T  s_xy,
T  px,
T  py,
int  reverse = 0 
)
template<typename T>
void UT_Matrix3T< T >::zero ( )
inline

Set the matrix to zero.

Definition at line 947 of file UT_Matrix3.h.

Friends And Related Function Documentation

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

Definition at line 1041 of file UT_Matrix3.h.

Member Data Documentation

template<typename T>
T UT_Matrix3T< T >::matx[3][3]

Definition at line 1084 of file UT_Matrix3.h.

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

Definition at line 1085 of file UT_Matrix3.h.

template<typename T>
const int UT_Matrix3T< T >::tuple_size = 9
static

Definition at line 88 of file UT_Matrix3.h.


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