|
3es
0.7
|
A row major 3x3 rotation matrix. More...
#include <3esmatrix3.h>
Public Member Functions | |
| Matrix3 () | |
| Empty constructor; contents are undefined. | |
| Matrix3 (const T *array9) | |
| Array initialisation constructor from an array of at least 9 elements. More... | |
| Matrix3 (const Matrix3< T > &other) | |
| Copy constructor. More... | |
| template<typename Q > | |
| Matrix3 (const Matrix3< Q > &other) | |
| Copy constructor from a different numeric type. More... | |
| Matrix3 (const T &rc00, const T &rc01, const T &rc02, const T &rc10, const T &rc11, const T &rc12, const T &rc20, const T &rc21, const T &rc22) | |
| Per element constructor, specifying each row in order. More... | |
| T & | operator() (int r, int c) |
| Row/column access. More... | |
| const T & | operator() (int r, int c) const |
| Row/column immutable access. More... | |
| T & | operator[] (int index) |
| Indexing operator (no bounds checking). More... | |
| const T & | operator[] (int index) const |
| Indexing operator (no bounds checking). More... | |
| Matrix3< T > & | initRotationX (const T &angle) |
| Matrix3< T > & | initRotationY (const T &angle) |
| Matrix3< T > & | initRotationZ (const T &angle) |
| Matrix3< T > & | initRotation (const T &x, const T &y, const T &z) |
| Matrix3< T > & | initScaling (const Vector3< T > &scale) |
| Matrix3< T > & | initLookAt (const Vector3< T > &eye, const Vector3< T > &target, const Vector3< T > &axisUp, int forwardAxisIndex=1, int upAxisIndex=2) |
| Initialise this matrix as a model or camera matrix. More... | |
| Matrix3< T > & | transpose () |
| Transposes this matrix. More... | |
| Matrix3< T > | transposed () const |
| Returns the transpose of this matrix, leaving this matrix unchanged. More... | |
| Matrix3< T > & | invert () |
| Inverts this matrix. More... | |
| Matrix3< T > | inverse () const |
| Returns the inverse of this matrix, leaving this matrix unchanged. More... | |
| T | getAdjoint (Matrix3< T > &adj) const |
| Gets the adjoint of this matrix. More... | |
| Matrix3< T > & | rigidBodyInvert () |
| Inverts this matrix assuming this matrix represents a rigid body transformation. More... | |
| Matrix3< T > | rigidBodyInverse () const |
| Returns the inverse of this matrix assuming this is a rigid body transformation. More... | |
| T | determinant () const |
| Calculates the determinant of this matrix. More... | |
| Vector3< T > | axisX () const |
| Returns the X axis of this matrix (elements (0, 0), (1, 0), (2, 0)). More... | |
| Vector3< T > | axisY () const |
| Returns the Y axis of this matrix (elements (0, 1), (1, 1), (2, 1)). More... | |
| Vector3< T > | axisZ () const |
| Returns the Z axis of this matrix (elements (0, 2), (1, 2), (2, 2)). More... | |
| Vector3< T > | axis (int index) const |
| Returns one of the axes of this matrix. More... | |
| Matrix3< T > & | setAxisX (const Vector3< T > &axis) |
| Sets the X axis of this matrix. More... | |
| Matrix3< T > & | setAxisY (const Vector3< T > &axis) |
| Sets the Y axis of this matrix. More... | |
| Matrix3< T > & | setAxisZ (const Vector3< T > &axis) |
| Sets the Z axis of this matrix. More... | |
| Matrix3< T > & | setAxis (int index, const Vector3< T > &axis) |
| Sets the indexed axis of this matrix. More... | |
| Vector3< T > | scale () const |
| Returns the scale contained in this matrix. More... | |
| Matrix3< T > & | scale (const Vector3< T > &scaling) |
| Scales this matrix, adjusting the scale of each rotation, but leaving the translation. More... | |
| Vector3< T > | transform (const Vector3< T > &v) const |
Transforms the vector v by this matrix. More... | |
| Vector3< T > | rotate (const Vector3< T > &v) const |
An alias for transform(). More... | |
Static Public Member Functions | |
| static Matrix3< T > | rotationX (const T &angle) |
| Create a matrix which represents a rotation around the X axis. More... | |
| static Matrix3< T > | rotationY (const T &angle) |
| Create a matrix which represents a rotation around the Y axis. More... | |
| static Matrix3< T > | rotationZ (const T &angle) |
| Create a matrix which represents a rotation around the Z axis. More... | |
| static Matrix3< T > | rotation (const T &x, const T &y, const T &z) |
| Create a matrix which represents a rotation around each axis (Euler angles). More... | |
| static Matrix3< T > | scaling (const Vector3< T > &scale) |
| Create a scaling matrix. More... | |
| static Matrix3< T > | lookAt (const Vector3< T > &eye, const Vector3< T > &target, const Vector3< T > &axisUp, int forwardAxisIndex=1, int upAxisIndex=2) |
Create a model or camera matrix at eye looking at target. More... | |
Public Attributes | |
| union { | |
| T rc [3][3] | |
| Row/column indexing representation. | |
| T m [9] | |
| Array representation. | |
| }; | |
Static Public Attributes | |
| static const Matrix3< T > | zero |
| A matrix with all zero elements. | |
| static const Matrix3< T > | identity |
| The identity matrix. | |
A row major 3x3 rotation matrix.
The matrix is laid out as follows:
Where (xx, xy, xz) are the components of the X axis. Similarly, yn and zn form the Y axis and Z axis of the basis vectors respectively.
| tes::Matrix3< T >::Matrix3 | ( | const T * | array9 | ) |
Array initialisation constructor from an array of at least 9 elements.
No bounds checking.
| array9 | The array of at least 9 value to initialise from. |
| tes::Matrix3< T >::Matrix3 | ( | const Matrix3< T > & | other | ) |
Copy constructor.
| other | The matrix to copy from. |
Copy constructor from a different numeric type.
| other | The matrix to copy from. |
| tes::Matrix3< T >::Matrix3 | ( | const T & | rc00, |
| const T & | rc01, | ||
| const T & | rc02, | ||
| const T & | rc10, | ||
| const T & | rc11, | ||
| const T & | rc12, | ||
| const T & | rc20, | ||
| const T & | rc21, | ||
| const T & | rc22 | ||
| ) |
Per element constructor, specifying each row in order.
| rc00 | Element at row/column 00 |
| rc01 | Element at row/column 01 |
| rc02 | Element at row/column 02 |
| rc10 | Element at row/column 10 |
| rc11 | Element at row/column 11 |
| rc12 | Element at row/column 12 |
| rc20 | Element at row/column 20 |
| rc21 | Element at row/column 21 |
| rc22 | Element at row/column 22 |
| Vector3<T> tes::Matrix3< T >::axis | ( | int | index | ) | const |
Returns one of the axes of this matrix.
| index | The index of the axis of interest. 0 => X, 1 => Y, 2 => Z. |
Referenced by tes::Matrix3< T >::initLookAt().
| Vector3<T> tes::Matrix3< T >::axisX | ( | ) | const |
Returns the X axis of this matrix (elements (0, 0), (1, 0), (2, 0)).
Referenced by tes::Matrix3< T >::initLookAt().
| Vector3<T> tes::Matrix3< T >::axisY | ( | ) | const |
Returns the Y axis of this matrix (elements (0, 1), (1, 1), (2, 1)).
Referenced by tes::Matrix3< T >::initLookAt().
| Vector3<T> tes::Matrix3< T >::axisZ | ( | ) | const |
Returns the Z axis of this matrix (elements (0, 2), (1, 2), (2, 2)).
Referenced by tes::Matrix3< T >::initLookAt().
| T tes::Matrix3< T >::determinant | ( | ) | const |
Calculates the determinant of this matrix.
Referenced by tes::Matrix3< T >::initLookAt().
| T tes::Matrix3< T >::getAdjoint | ( | Matrix3< T > & | adj | ) | const |
Gets the adjoint of this matrix.
| [out] | m | The adjoint is written here. |
Referenced by tes::Matrix3< T >::initLookAt().
|
inline |
Initialise this matrix as a model or camera matrix.
lookAt(). | eye | The position of the eye/camera (dropped after rotation is calculated). |
| target | The target to look at. Should not be equal to eye. |
| axisUp | The axis defining the initial up vector. Must be normalised. |
| forwardAxisIndex | The index of the forward axis. This is to point at target. |
| upAxisIndex | The index of the up axis. Must not be equal to forwardAxisIndex. |
this References tes::Matrix3< T >::axis(), tes::Matrix3< T >::axisX(), tes::Matrix3< T >::axisY(), tes::Matrix3< T >::axisZ(), tes::Matrix3< T >::determinant(), tes::Matrix3< T >::getAdjoint(), tes::Matrix3< T >::inverse(), tes::Matrix3< T >::invert(), tes::Matrix3< T >::lookAt(), tes::Matrix3< T >::rigidBodyInverse(), tes::Matrix3< T >::rigidBodyInvert(), tes::Matrix3< T >::rotate(), tes::Matrix3< T >::scale(), tes::Matrix3< T >::setAxis(), tes::Matrix3< T >::setAxisX(), tes::Matrix3< T >::setAxisY(), tes::Matrix3< T >::setAxisZ(), tes::Matrix3< T >::transform(), tes::Matrix3< T >::transpose(), and tes::Matrix3< T >::transposed().
| Matrix3<T> tes::Matrix3< T >::inverse | ( | ) | const |
Returns the inverse of this matrix, leaving this matrix unchanged.
Referenced by tes::Matrix3< T >::initLookAt().
| Matrix3<T>& tes::Matrix3< T >::invert | ( | ) |
Inverts this matrix.
Referenced by tes::Matrix3< T >::initLookAt().
|
static |
Create a model or camera matrix at eye looking at target.
Supports specifying the up and forward axes (inferring the left/right axis), where the indices [0, 1, 2] correspond to the axes (X, Y, Z).
The default behaviour is to use Y as the forward axis and Z as up.
Note: the resulting matrix can only represent the rotation part of the matrix and the eye translation is essentially dropped. Use Matrix4 where the translation is required.
| eye | The position of the eye/camera (dropped after rotation is calculated). |
| target | The target to look at. Should not be equal to eye. |
| axisUp | The axis defining the initial up vector. Must be normalised. |
| forwardAxisIndex | The index of the forward axis. This is to point at target. |
| upAxisIndex | The index of the up axis. Must not be equal to forwardAxisIndex. |
eye pointing at target. Returns identity if there are errors in the specification of forwardAxisIndex and upAxisIndex. Referenced by tes::Matrix3< T >::initLookAt(), and tes::Matrix3< T >::operator[]().
|
inline |
Row/column access.
Not bounds checked.
| r | The row to access [0, 2] |
| c | The column to access [0, 2]. |
References tes::Matrix3< T >::rc.
|
inline |
Row/column immutable access.
Not bounds checked.
| r | The row to access [0, 2] |
| c | The column to access [0, 2]. |
References tes::Matrix3< T >::rc.
|
inline |
Indexing operator (no bounds checking).
| index | The element to access [0, 9]. |
index. References tes::Matrix3< T >::m.
|
inline |
Indexing operator (no bounds checking).
| index | The element to access [0, 9]. |
index. References tes::Matrix3< T >::lookAt(), tes::Matrix3< T >::m, tes::Matrix3< T >::rotation(), tes::Matrix3< T >::rotationX(), tes::Matrix3< T >::rotationY(), tes::Matrix3< T >::rotationZ(), tes::Matrix3< T >::scale(), and tes::Matrix3< T >::scaling().
| Matrix3<T> tes::Matrix3< T >::rigidBodyInverse | ( | ) | const |
Returns the inverse of this matrix assuming this is a rigid body transformation.
See rigidBodyInvert().
Referenced by tes::Matrix3< T >::initLookAt().
| Matrix3<T>& tes::Matrix3< T >::rigidBodyInvert | ( | ) |
Inverts this matrix assuming this matrix represents a rigid body transformation.
A rigid body transformation contains no skewing. That is, the basis vectors are orthogonal.
The inverse is calculated by transposing the rotation and inverting the translation.
Referenced by tes::Matrix3< T >::initLookAt().
| Vector3<T> tes::Matrix3< T >::rotate | ( | const Vector3< T > & | v | ) | const |
An alias for transform().
Referenced by tes::Matrix3< T >::initLookAt().
|
static |
Create a matrix which represents a rotation around each axis (Euler angles).
Rotations are applied in x, y, z order.
| x | Rotation around the X axis (radians). |
| y | Rotation around the Y axis (radians). |
| z | Rotation around the Z axis (radians). |
Referenced by tes::Matrix3< T >::operator[]().
|
static |
Create a matrix which represents a rotation around the X axis.
| angle | The rotation angle in radians. |
Referenced by tes::Matrix3< T >::operator[]().
|
static |
Create a matrix which represents a rotation around the Y axis.
| angle | The rotation angle in radians. |
Referenced by tes::Matrix3< T >::operator[]().
|
static |
Create a matrix which represents a rotation around the Z axis.
| angle | The rotation angle in radians. |
Referenced by tes::Matrix3< T >::operator[]().
| Vector3<T> tes::Matrix3< T >::scale | ( | ) | const |
Returns the scale contained in this matrix.
This is the length of each axis.
Referenced by tes::Matrix3< T >::initLookAt(), and tes::Matrix3< T >::operator[]().
| Matrix3<T>& tes::Matrix3< T >::scale | ( | const Vector3< T > & | scaling | ) |
Scales this matrix, adjusting the scale of each rotation, but leaving the translation.
| scaling | The scaling to apply. |
|
static |
Create a scaling matrix.
| scale | The scaling to apply along each axis. |
Referenced by tes::Matrix3< T >::operator[]().
| Matrix3<T>& tes::Matrix3< T >::setAxis | ( | int | index, |
| const Vector3< T > & | axis | ||
| ) |
Sets the indexed axis of this matrix.
See axis().
| index | The index of the axis of interest. 0 => X, 1 => Y, 2 => Z. |
| axis | The value to set the axis to. |
Referenced by tes::Matrix3< T >::initLookAt().
| Matrix3<T>& tes::Matrix3< T >::setAxisX | ( | const Vector3< T > & | axis | ) |
Sets the X axis of this matrix.
See axisX().
| axis | The value to set the axis to. |
Referenced by tes::Matrix3< T >::initLookAt().
| Matrix3<T>& tes::Matrix3< T >::setAxisY | ( | const Vector3< T > & | axis | ) |
Sets the Y axis of this matrix.
See axisY().
| axis | The value to set the axis to. |
Referenced by tes::Matrix3< T >::initLookAt().
| Matrix3<T>& tes::Matrix3< T >::setAxisZ | ( | const Vector3< T > & | axis | ) |
Sets the Z axis of this matrix.
See axisZ().
| axis | The value to set the axis to. |
Referenced by tes::Matrix3< T >::initLookAt().
| Vector3<T> tes::Matrix3< T >::transform | ( | const Vector3< T > & | v | ) | const |
Transforms the vector v by this matrix.
Referenced by tes::Matrix3< T >::initLookAt().
| Matrix3<T>& tes::Matrix3< T >::transpose | ( | ) |
Transposes this matrix.
Referenced by tes::Matrix3< T >::initLookAt().
| Matrix3<T> tes::Matrix3< T >::transposed | ( | ) | const |
Returns the transpose of this matrix, leaving this matrix unchanged.
Referenced by tes::Matrix3< T >::initLookAt().