SLProject 4.0.000
|
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 |
T | 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... | |
T | trace () const |
T | 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 | |
T | _m [9] |
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
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< T >::SLMat3 | ( | const T | angleDEG, |
const T | axis_x, | ||
const T | axis_y, | ||
const T | axis_z | ||
) |
Sets rotate matrix from axis & angle.
Sets rotate matrix.
Sets rotation matrix from Euler angles in radians.
|
inline |
det returns the determinant
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
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
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
void SLMat3< T >::identity |
void SLMat3< T >::invert |
Inverts the matrix.
Returns the inverse of the matrix and leaves itself unchanged.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Sets the rotation components
void SLMat3< T >::rotation | ( | const T | angleDEG, |
const T | axisx, | ||
const T | axisy, | ||
const T | axisz | ||
) |
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
void SLMat3< T >::scale | ( | const T | s | ) |
void SLMat3< T >::scale | ( | const T | sx, |
const T | sy, | ||
const T | sz | ||
) |
Sets the scaling components.
void SLMat3< T >::setMatrix | ( | const T * | M | ) |
void SLMat3< T >::setMatrix | ( | T | M0, |
T | M3, | ||
T | M6, | ||
T | M1, | ||
T | M4, | ||
T | M7, | ||
T | M2, | ||
T | M5, | ||
T | M8 | ||
) |
|
inlinestatic |
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.
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
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
|
inline |
void SLMat3< T >::transpose |
Transposes the matrix.
Returns the transposed of the matrix and leaves the itself unchanged.
T SLMat3< T >::_m[9] |