SLProject 4.0.000
SLMat3< T > Class Template Reference

3x3 matrix template class More...

#include <SLMat3.h>

Public Member Functions

 SLMat3 ()
 Sets identity matrix. More...
 
 SLMat3 (const SLMat3 &A)
 Sets mat by other SLMat3. More...
 
 SLMat3 (const T M0, const T M3, const T M6, const T M1, const T M4, const T M7, const T M2, const T M5, const T M8)
 Sets matrix by components. More...
 
 SLMat3 (const T angleDEG, const T axis_x, const T axis_y, const T axis_z)
 Sets rotate matrix from axis & angle. More...
 
 SLMat3 (const T angleDEG, const SLVec3< T > axis)
 Sets rotate matrix. More...
 
 SLMat3 (const T scale_xyz)
 Sets uniform scaling matrix. More...
 
 SLMat3 (const T angleXRAD, const T angleYRAD, const T angleZRAD)
 Sets rotation matrix from Euler angles in radians. More...
 
void setMatrix (const SLMat3 &A)
 
void setMatrix (const SLMat3 *A)
 
void setMatrix (const T *M)
 
void setMatrix (T M0, T M3, T M6, T M1, T M4, T M7, T M2, T M5, T M8)
 
void m (int i, T val)
 
const T * m () const
 
m (int i) const
 
SLMat3< T > & operator= (const SLMat3 &A)
 
SLMat3< T > & operator*= (const SLMat3 &A)
 
SLMat3< T > & operator= (const T *a)
 
SLMat3< T > operator+ (const SLMat3 &A) const
 
SLMat3< T > operator- (const SLMat3 &A) const
 
SLMat3< T > operator* (const SLMat3 &A) const
 
SLVec3< T > operator* (const SLVec3< T > &v) const
 
SLMat3< T > operator* (T a) const
 scalar multiplication More...
 
SLMat3< T > & operator*= (T a)
 scalar multiplication More...
 
SLMat3< T > operator/ (T a) const
 scalar division More...
 
SLMat3< T > & operator/= (T a)
 scalar division More...
 
 operator const T * () const
 
 operator T* ()
 
T & operator() (SLint row, SLint col)
 
const T & operator() (SLint row, SLint col) const
 
void rotation (const T angleDEG, const SLVec3< T > &axis)
 Sets the rotation components
More...
 
void rotation (const T angleDEG, const T axisx, const T axisy, const T axisz)
 
void rotation (const T zAngleRAD, const T yAngleRAD, const T xAngleRAD)
 
void scale (const T sx, const T sy, const T sz)
 Sets the scaling components. More...
 
void scale (const SLVec3< T > &s)
 
void scale (const T s)
 
void identity ()
 
void transpose ()
 Transposes the matrix. More...
 
SLMat3< T > transposed () const
 Returns the transposed of the matrix and leaves the itself unchanged. More...
 
void invert ()
 Inverts the matrix. More...
 
SLMat3< T > inverted ()
 Returns the inverse of the matrix and leaves itself unchanged. More...
 
trace () const
 
det () const
 det returns the determinant More...
 
void toAngleAxis (T &angleDEG, SLVec3< T > &axis) const
 Conversion to axis and angle in radians. More...
 
void toEulerAnglesXYZ (T &xRotRAD, T &yRotRAD, T &zRotRAD)
 
void toEulerAnglesZYX (T &zRotRAD, T &yRotRAD, T &xRotRAD)
 
void fromEulerAnglesXYZ (const T angleXRAD, const T angleYRAD, const T angleZRAD)
 
void fromEulerAnglesZYX (const T angleZ1RAD, const T angleY2RAD, const T angleX3RAD)
 
void fromEulerAnglesZXZ (const T angleZ1RAD, const T angleX2RAD, const T angleZ2RAD)
 
void print (const SLchar *str) const
 

Static Public Member Functions

static void swap (T &a, T &b)
 

Public Attributes

_m [9]
 

Detailed Description

template<class T>
class SLMat3< T >

3x3 matrix template class

Implements a 3 by 3 matrix template. 9 floats were used instead of the normal [3][3] array. The order is columnwise as in OpenGL

| 0 3 6 | | 1 4 7 | | 2 5 8 |


type definitions for 3x3 matrice:
Use SLMat3f for a specific float type 3x3 matrix
Use SLMat3d for a specific double type 3x3 matrix

Constructor & Destructor Documentation

◆ SLMat3() [1/7]

template<class T >
SLMat3< T >::SLMat3

Sets identity matrix.

◆ SLMat3() [2/7]

template<class T >
SLMat3< T >::SLMat3 ( const SLMat3< T > &  A)

Sets mat by other SLMat3.

◆ SLMat3() [3/7]

template<class T >
SLMat3< T >::SLMat3 ( const T  M0,
const T  M3,
const T  M6,
const T  M1,
const T  M4,
const T  M7,
const T  M2,
const T  M5,
const T  M8 
)

Sets matrix by components.

◆ SLMat3() [4/7]

template<class T >
SLMat3< T >::SLMat3 ( const T  angleDEG,
const T  axis_x,
const T  axis_y,
const T  axis_z 
)

Sets rotate matrix from axis & angle.

◆ SLMat3() [5/7]

template<class T >
SLMat3< T >::SLMat3 ( const T  angleDEG,
const SLVec3< T >  axis 
)

Sets rotate matrix.

◆ SLMat3() [6/7]

template<class T >
SLMat3< T >::SLMat3 ( const T  scale_xyz)

Sets uniform scaling matrix.

◆ SLMat3() [7/7]

template<class T >
SLMat3< T >::SLMat3 ( const T  angleXRAD,
const T  angleYRAD,
const T  angleZRAD 
)

Sets rotation matrix from Euler angles in radians.

Member Function Documentation

◆ det()

template<class T >
T SLMat3< T >::det
inline

det returns the determinant

◆ fromEulerAnglesXYZ()

template<class T >
void SLMat3< T >::fromEulerAnglesXYZ ( const T  angleX1RAD,
const T  angleY2RAD,
const T  angleZ3RAD 
)

Sets the linear 3x3 sub-matrix as a rotation matrix from the 3 euler angles in radians around the z-axis, y-axis & x-axis := Rx * Ry * Rz See: http://en.wikipedia.org/wiki/Euler_angles

◆ fromEulerAnglesZXZ()

template<class T >
void SLMat3< T >::fromEulerAnglesZXZ ( const T  angleZ1RAD,
const T  angleX2RAD,
const T  angleZ3RAD 
)

Sets the linear 3x3 sub-matrix as a rotation matrix from the 3 euler angles in radians around the z-axis, x-axis & z-axis:= Z1*X2*Z3 See: http://en.wikipedia.org/wiki/Euler_angles

◆ fromEulerAnglesZYX()

template<class T >
void SLMat3< T >::fromEulerAnglesZYX ( const T  angleZ1RAD,
const T  angleY2RAD,
const T  angleX3RAD 
)

Sets the linear 3x3 sub-matrix as a rotation matrix from the 3 euler angles in radians around the x-axis, y-axis & z-axis := Rz * Ry * Rx See: http://en.wikipedia.org/wiki/Euler_angles

◆ identity()

template<class T >
void SLMat3< T >::identity

◆ invert()

template<class T >
void SLMat3< T >::invert

Inverts the matrix.

◆ inverted()

template<class T >
SLMat3< T > SLMat3< T >::inverted

Returns the inverse of the matrix and leaves itself unchanged.

◆ m() [1/3]

template<class T >
const T * SLMat3< T >::m ( ) const
inline

◆ m() [2/3]

template<class T >
T SLMat3< T >::m ( int  i) const
inline

◆ m() [3/3]

template<class T >
void SLMat3< T >::m ( int  i,
val 
)
inline

◆ operator const T *()

template<class T >
SLMat3< T >::operator const T * ( ) const
inline

◆ operator T*()

template<class T >
SLMat3< T >::operator T* ( )
inline

◆ operator()() [1/2]

template<class T >
T & SLMat3< T >::operator() ( SLint  row,
SLint  col 
)
inline

◆ operator()() [2/2]

template<class T >
const T & SLMat3< T >::operator() ( SLint  row,
SLint  col 
) const
inline

◆ operator*() [1/3]

template<class T >
SLMat3< T > SLMat3< T >::operator* ( const SLMat3< T > &  A) const

◆ operator*() [2/3]

template<class T >
SLVec3< T > SLMat3< T >::operator* ( const SLVec3< T > &  v) const

◆ operator*() [3/3]

template<class T >
SLMat3< T > SLMat3< T >::operator* ( a) const

scalar multiplication

◆ operator*=() [1/2]

template<class T >
SLMat3< T > & SLMat3< T >::operator*= ( const SLMat3< T > &  A)

◆ operator*=() [2/2]

template<class T >
SLMat3< T > & SLMat3< T >::operator*= ( a)

scalar multiplication

◆ operator+()

template<class T >
SLMat3< T > SLMat3< T >::operator+ ( const SLMat3< T > &  A) const

◆ operator-()

template<class T >
SLMat3< T > SLMat3< T >::operator- ( const SLMat3< T > &  A) const

◆ operator/()

template<class T >
SLMat3< T > SLMat3< T >::operator/ ( a) const

scalar division

◆ operator/=()

template<class T >
SLMat3< T > & SLMat3< T >::operator/= ( a)

scalar division

◆ operator=() [1/2]

template<class T >
SLMat3< T > & SLMat3< T >::operator= ( const SLMat3< T > &  A)

◆ operator=() [2/2]

template<class T >
SLMat3< T > & SLMat3< T >::operator= ( const T *  a)

◆ print()

template<class T >
void SLMat3< T >::print ( const SLchar str) const

◆ rotation() [1/3]

template<class T >
void SLMat3< T >::rotation ( const T  angleDEG,
const SLVec3< T > &  axis 
)

Sets the rotation components

◆ rotation() [2/3]

template<class T >
void SLMat3< T >::rotation ( const T  angleDEG,
const T  axisx,
const T  axisy,
const T  axisz 
)

◆ rotation() [3/3]

template<class T >
void SLMat3< T >::rotation ( const T  zAngleRAD,
const T  yAngleRAD,
const T  xAngleRAD 
)

Sets the matrix as a rotation matrix from the 3 euler angles in radians around the z-axis, y-axis & x-axis. See Van Verth: Essential Math for Games, chapter 5: Orientation Representation

◆ scale() [1/3]

template<class T >
void SLMat3< T >::scale ( const SLVec3< T > &  s)

◆ scale() [2/3]

template<class T >
void SLMat3< T >::scale ( const T  s)

◆ scale() [3/3]

template<class T >
void SLMat3< T >::scale ( const T  sx,
const T  sy,
const T  sz 
)

Sets the scaling components.

◆ setMatrix() [1/4]

template<class T >
void SLMat3< T >::setMatrix ( const SLMat3< T > &  A)

◆ setMatrix() [2/4]

template<class T >
void SLMat3< T >::setMatrix ( const SLMat3< T > *  A)

◆ setMatrix() [3/4]

template<class T >
void SLMat3< T >::setMatrix ( const T *  M)

◆ setMatrix() [4/4]

template<class T >
void SLMat3< T >::setMatrix ( M0,
M3,
M6,
M1,
M4,
M7,
M2,
M5,
M8 
)

◆ swap()

template<class T >
static void SLMat3< T >::swap ( T &  a,
T &  b 
)
inlinestatic

◆ toAngleAxis()

template<typename T >
void SLMat3< T >::toAngleAxis ( T &  angleDEG,
SLVec3< T > &  axis 
) const

Conversion to axis and angle in radians.

The matrix must be a rotation matrix for this functions to be valid. The last function uses Gram-Schmidt orthonormalization applied to the columns of the rotation matrix. The angle must be in radians, not degrees.

◆ toEulerAnglesXYZ()

template<class T >
void SLMat3< T >::toEulerAnglesXYZ ( T &  xRotRAD,
T &  yRotRAD,
T &  zRotRAD 
)

Gets one set of possible x-y-z euler angles that will generate this matrix Source: Essential Mathematics for Games and Interactive Applications A Programmer's Guide 2nd edition by James M. Van Verth and Lars M. Bishop

◆ toEulerAnglesZYX()

template<class T >
void SLMat3< T >::toEulerAnglesZYX ( T &  zRotRAD,
T &  yRotRAD,
T &  xRotRAD 
)

Gets one set of possible z-y-x euler angles that will generate this matrix Source: Essential Mathematics for Games and Interactive Applications A Programmer's Guide 2nd edition by James M. Van Verth and Lars M. Bishop

◆ trace()

template<class T >
T SLMat3< T >::trace
inline

◆ transpose()

template<class T >
void SLMat3< T >::transpose

Transposes the matrix.

◆ transposed()

template<class T >
SLMat3< T > SLMat3< T >::transposed

Returns the transposed of the matrix and leaves the itself unchanged.

Member Data Documentation

◆ _m

template<class T >
T SLMat3< T >::_m[9]

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