Maria GDK 5.0.0.738
Documentation of native code in develop branch
Loading...
Searching...
No Matches
STK::Matrix4x4< Type > Class Template Reference

Classes

struct  matType
 

Public Types

enum  {
  IDENTITY = 0x0 , ROTATION = 0x1 , UNIFORM_SCALE = 0x2 , TRANSLATION = 0x4 ,
  AFFINE = 0x8 , PROJECTION = 0x10 , UNKNOWN = 0xff , ZERO = 0x200 ,
  SINGULAR = 0x600
}
 

Public Member Functions

 Matrix4x4 (Type m00, Type m01, Type m02, Type m03, Type m10, Type m11, Type m12, Type m13, Type m20, Type m21, Type m22, Type m23, Type m30, Type m31, Type m32, Type m33)
 
template<typename U , STK::enable_if_safe_cast_t< U, Type > = true>
 Matrix4x4 (const Matrix4x4< U > &other)
 
void setArray (Type *arr)
 
void setIdentity ()
 
void setZero ()
 
const Type & operator() (int row, int col) const
 Return element at row, column.
 
Type & operator() (int row, int col)
 Return element at row, column.
 
const Type * getVal () const
 
int getTransType () const
 
void setTransType (int tt)
 
void setTransTypeFields (int tt)
 
void unSetTransTypeFields (int tt)
 
bool isIdentity () const
 
Matrix4x4transpose ()
 Matrix manipulation functions.
 
Matrix4x4transposeRot ()
 Transpose the rotation matrix.
 
Matrix4x4transposeNegate ()
 
Matrix4x4inverse ()
 Invert this matrix.
 
void getCol (int col, Vector3< Type > &v) const
 
Vector3< Type > getCol (int col) const
 
void setCol (int col, const Vector3< Type > &v)
 
void getRow (int row, Vector3< Type > &v) const
 
Vector3< Type > getRow (int row) const
 
void setRow (int row, const Vector3< Type > &v)
 
void getCol (int col, Vector4< Type > &v) const
 
void setCol (int col, const Vector4< Type > &v)
 
void getRow (int row, Vector4< Type > &v) const
 
void setRow (int row, const Vector4< Type > &v)
 
void setRotateX (Type a)
 
void rotateX (Type a)
 
void setRotateY (Type a)
 
void rotateY (Type a)
 
void setRotateZ (Type a)
 
void rotateZ (Type a)
 
void setRotate (Type a, Type x, Type y, Type z)
 Rotate a degrees about the vector $[x, y, z]^T$.
 
void rotate (Type a, Type x, Type y, Type z)
 
void setRotate (Type a, const Vector3< Type > &v)
 Rotate a radians about the vector v.
 
void rotate (Type a, const Vector3< Type > &v)
 
void setScale (Type s)
 Scale by s units.
 
void scale (Type s)
 Multiplies the current matrix with a uniform scale matrix.
 
void setScale (Type x, Type y, Type z)
 Scale.
 
void setScale (const Vector3< Type > &s)
 
void scale (Type x, Type y, Type z)
 Multiplies the current matrix with a scale matrix.
 
void scale (const Vector3< Type > &s)
 
void setTranslate (Type x, Type y, Type z)
 Translate with vector $[x, y, z]^T$.
 
void translate (Type x, Type y, Type z)
 Multiplies the current matrix with a translation matrix.
 
void setTranslate (const Vector3< Type > &v)
 Translate with vector v.
 
void translate (const Vector3< Type > &v)
 Multiplies the current matrix with a translation matrix.
 
void setEuler (Type heading, Type pitch, Type roll)
 
void euler (Type heading, Type pitch, Type roll)
 Multiplies the current matrix with an euler matrix.
 
void setEuler (Type x, Type y, Type z, Type heading, Type pitch, Type roll)
 
void euler (Type x, Type y, Type z, Type heading, Type pitch, Type roll)
 Multiplies the current matrix with an euler + translation matrix.
 
void setEuler (const Vector3< Type > &p, Type heading, Type pitch, Type roll)
 
void euler (const Vector3< Type > &p, Type heading, Type pitch, Type roll)
 Multiplies the current matrix with an euler + translation matrix.
 
void setLookAt (const Vector3< Type > &pos, const Vector3< Type > &ctr, const Vector3< Type > &up)
 
void lookAt (const Vector3< Type > &pos, const Vector3< Type > &ctr, const Vector3< Type > &up)
 Multiplies the current matrix with an lookAt matrix.
 
void setPerspective (Type vertical_fov, Type aspect, Type near_plane, Type far_plane)
 
void perspective (Type vertical_fov, Type aspect, Type near_plane, Type far_plane)
 Multiplies the current matrix with a perspective matrix.
 
void setOrtho (Type left, Type right, Type bottom, Type top, Type near_plane, Type far_plane)
 
void ortho (Type left, Type right, Type bottom, Type top, Type near_plane, Type far_plane)
 Multiplies the current matrix with an orthographic matrix.
 
Matrix4x4 operator* (const Matrix4x4 &t) const
 Scalar multiplication.
 
Matrix4x4operator*= (const Matrix4x4 &t)
 Scalar multiplication.
 
Vector3< Type > transformVector (const Vector3< Type > &v) const
 Scalar multiplication.
 
Vector3< Type > transformVector (const Vector2< Type > &v) const
 Scalar multiplication.
 
Vector3< Type > transformPoint (const Vector3< Type > &v) const
 Scalar multiplication.
 
Vector3< Type > transformPoint (const Vector2< Type > &v) const
 Scalar multiplication.
 
bool fuzzyCompare (const Matrix4x4 &t, Type eps) const
 

Static Public Member Functions

static Matrix4x4 getInverse (const Matrix4x4 &m)
 Return the inverse of the input matrix.
 
static Matrix4x4 calcNormalMatrix (const Matrix4x4 &m)
 

Protected Member Functions

void setMult (const Matrix4x4 &s, const Matrix4x4 &t)
 
bool simplifiedInverse ()
 
bool setGauss (Matrix4x4 t)
 

Protected Attributes

union {
   Type   m_ [4][4]
 
   matType   e_
 
}; 
 
int trans_type_
 

Friends

std::ostream & operator<< (std::ostream &os, const Matrix4x4 &t)
 
bool operator== (const Matrix4x4 &t1, const Matrix4x4 &t2)
 
bool operator!= (const Matrix4x4 &t1, const Matrix4x4 &t2)
 
Vector4< Type > operator* (const Matrix4x4 &m, const Vector4< Type > &v)
 Scalar multiplication.
 

Member Function Documentation

◆ calcNormalMatrix()

template<class Type >
static Matrix4x4 STK::Matrix4x4< Type >::calcNormalMatrix ( const Matrix4x4< Type > &  m)
inlinestatic

Calculate the normal matrix. The normal matrix is defined to be the transpose of the inverse of the upper left 3x3 sub-matrix

◆ rotate() [1/2]

template<class Type >
void STK::Matrix4x4< Type >::rotate ( Type  a,
const Vector3< Type > &  v 
)
inline

Multiplies the current matrix with a rotation about an axis

See also
setRotate()

◆ rotate() [2/2]

template<class Type >
void STK::Matrix4x4< Type >::rotate ( Type  a,
Type  x,
Type  y,
Type  z 
)
inline

Multiplies the current matrix with a rotation about an axis

See also
setRotate()

◆ rotateX()

template<class Type >
void STK::Matrix4x4< Type >::rotateX ( Type  a)
inline

Multiplies the current matrix with a rotation about the x-axis

See also
setRotateX()

◆ rotateY()

template<class Type >
void STK::Matrix4x4< Type >::rotateY ( Type  a)
inline

Multiplies the current matrix with a rotation about the y-axis

See also
setRotateY()

◆ rotateZ()

template<class Type >
void STK::Matrix4x4< Type >::rotateZ ( Type  a)
inline

Multiplies the current matrix with a rotation about the y-axis

See also
setRotateZ()

◆ setEuler() [1/3]

template<class Type >
void STK::Matrix4x4< Type >::setEuler ( const Vector3< Type > &  p,
Type  heading,
Type  pitch,
Type  roll 
)
inline

Euler transform/translation. This method creates an Euler transform (see above) and translates to the point p.

◆ setEuler() [2/3]

template<class Type >
void STK::Matrix4x4< Type >::setEuler ( Type  heading,
Type  pitch,
Type  roll 
)
inline

Euler transform. This transform constructs a matrix to orient an object in a certain direction. This matrix consists of three rotations about the three coordinate axis. The transformation is given by the following equation

\[
\mathbf{E}(h, p, r) = \mathbf{R}_z(r)\mathbf{R}_x(p)\mathbf{R}_y(h)
\]

where $\mathbf{R}$ denotes a rotation matrix and $r, p, h$ (roll, pitch, heading), are the amounts of rotation about their respective axis given in degrees.

Warning
Note that certain combinations of rotations may lead to a "gimbal lock" (loss of one degree of freedom). To avoid this, use quaternions instead.
See also
Quaternion

◆ setEuler() [3/3]

template<class Type >
void STK::Matrix4x4< Type >::setEuler ( Type  x,
Type  y,
Type  z,
Type  heading,
Type  pitch,
Type  roll 
)
inline

Euler transform/translation. This method creates an Euler transform (see above) and translates to the point (x, y, z).

◆ setLookAt()

template<class Type >
void STK::Matrix4x4< Type >::setLookAt ( const Vector3< Type > &  pos,
const Vector3< Type > &  ctr,
const Vector3< Type > &  up 
)
inline

Create a camera matrix. This method creates a transformation matrix which transforms objects relative to a camera direction (pos), a camera direction (ctr) and an up vector (up).

◆ setPerspective()

template<class Type >
void STK::Matrix4x4< Type >::setPerspective ( Type  vertical_fov,
Type  aspect,
Type  near_plane,
Type  far_plane 
)
inline

Set to perspective transform. This method will fill the matrix with a perspective transform defined by:

Parameters
vertical_fovVertical field of view in degrees.
aspectAspect ratio (width/height). \near_plane Near clipping plane. \far_plane Far clipping plane.

◆ setRotateX()

template<class Type >
void STK::Matrix4x4< Type >::setRotateX ( Type  a)
inline

Rotate a degrees about the x-axis. A positive angle causes a clockwise rotation about the axis (seen from the origin), and a negative angle causes a counter- clockwise rotation.

◆ setRotateY()

template<class Type >
void STK::Matrix4x4< Type >::setRotateY ( Type  a)
inline

Rotate a degrees about the y-axis. A positive angle causes a clockwise rotation about the axis (seen from the origin), and a negative angle causes a counter- clockwise rotation.

◆ setRotateZ()

template<class Type >
void STK::Matrix4x4< Type >::setRotateZ ( Type  a)
inline

Rotate a degrees about the z-axis. A positive angle causes a clockwise rotation about the axis (seen from the origin), and a negative angle causes a counter- clockwise rotation.

◆ transformVector() [1/2]

template<class Type >
Vector3< Type > STK::Matrix4x4< Type >::transformVector ( const Vector2< Type > &  v) const
inline

Scalar multiplication.

Maps vector by multiplying the top 3x3 part of the matrix by the vector. Translation and projection are ignored.

◆ transformVector() [2/2]

template<class Type >
Vector3< Type > STK::Matrix4x4< Type >::transformVector ( const Vector3< Type > &  v) const
inline

Scalar multiplication.

Maps vector by multiplying the top 3x3 part of the matrix by the vector. Translation and projection are ignored.

◆ transposeNegate()

template<class Type >
Matrix4x4 & STK::Matrix4x4< Type >::transposeNegate ( )
inline

Transpose the rotation matrix, invert the translation vector. To use this function you have to be very sure that the transform only contains translation and rotation parts.

Member Data Documentation

◆ e_

template<class Type >
matType STK::Matrix4x4< Type >::e_

The single elements

◆ m_

template<class Type >
Type STK::Matrix4x4< Type >::m_[4][4]

The two dimensional array view


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