3rd Eye Scene C#
3rd Eye Scene C# documentation
|
A row major 4x4 transformation matrix. More...
Public Member Functions | |
Vector3 | GetAxis (int index) |
Requests an axis or column from the matrix, dropping the last row. | |
void | SetAxis (int index, Vector3 axis) |
Set an axis or column from the matrix. | |
void | InitRotationX (float angle) |
Sets this matrix to a rotation matrix around the X axis. | |
void | InitRotationY (float angle) |
Sets this matrix to a rotation matrix around the Y axis. | |
void | InitRotationZ (float angle) |
Sets this matrix to a rotation matrix around the Z axis. | |
void | InitTranslationMatrix (Vector3 trans) |
Initialise a translation matrix, no rotation or scale. | |
void | InitRotation (float angleX, float angleY, float angleZ) |
Initialise this matrix from the given Euler angles. | |
void | InitRotationTranslation (float angleX, float angleY, float angleZ, Vector3 trans) |
Initialise this matrix from the given Euler angles and translation. | |
void | InitScaling (Vector3 scale) |
Initialise this matrix as a scaling matrix. | |
void | ApplyScaling (Vector3 scaling) |
Scales the matrix basis vectors. | |
Vector3 | RemoveScale () |
Removes scaling from the matrix basis vectors. | |
void | InitLookAt (Vector3 eye, Vector3 target, Vector3 axisUp, int forwardAxisIndex=1, int upAxisIndex=2) |
Initialise this matrix as a model or camera matrix. | |
void | Transpose () |
Transpose this matrix. | |
void | Invert () |
Inverse this matrix. | |
void | RigidBodyInvert () |
Calculate the inverse of a rigid body matrix (no skew or scaling). | |
Vector3 | Transform (Vector3 v) |
Apply this transformation to the vector v . | |
Vector3 | Rotate (Vector3 v) |
Transforms the vector v by the rotation component of this matrix. | |
Static Public Member Functions | |
static Matrix4 | All (float val) |
Create a matrix with all components set to val . | |
static Matrix4 | IdentityMatrix () |
The 4x4 identity matrix. | |
static Matrix4 | RotationX (float angle) |
Builds a rotation matrix around the X axis. | |
static Matrix4 | RotationY (float angle) |
Sets this matrix to a rotation matrix around the Y axis. | |
static Matrix4 | RotationZ (float angle) |
Sets this matrix to a rotation matrix around the Z axis. | |
static Matrix4 | TranslationMatrix (Vector3 trans) |
Create a translation matrix, no rotation or scale. | |
static Matrix4 | Rotation (float angleX, float angleY, float angleZ) |
Build a rotation matrix from the given Euler angles. | |
static Matrix4 | RotationTranslation (float angleX, float angleY, float angleZ, Vector3 trans) |
Build a transformation matrix from the given Euler angles and translation. | |
static Matrix4 | Scaling (Vector3 scale) |
Initialise a scaling matrix. | |
static Matrix4 | LookAt (Vector3 eye, Vector3 target, Vector3 axisUp, int forwardAxisIndex=1, int upAxisIndex=2) |
Create a model or camera matrix at eye looking at target . | |
static Vector3 | operator* (Matrix4 a, Vector3 v) |
Calculates the transformation Av . | |
static Matrix4 | operator* (Matrix4 a, Matrix4 b) |
Calculates the matrix product of two 4x4 matrices. | |
Static Public Attributes | |
static Matrix4 | Zero = All(0.0f) |
A matrix with all zero components. | |
static Matrix4 | Identity = IdentityMatrix() |
The 4x4 identity matrix. | |
Properties | |
float | this[int index] [get, set] |
Indexing accessor across the range [0, 15]. | |
float | this[int r, int c] [get, set] |
Row/column indexing accessor. | |
float | Determinant [get] |
Calculate the determinant of this matrix. | |
Vector3 | AxisX [get, set] |
Get/set the conceptual X axis from this matrix. | |
Vector3 | AxisY [get, set] |
Get/set the conceptual Y axis from this matrix. | |
Vector3 | AxisZ [get, set] |
Get/set the conceptual Z axis from this matrix. | |
Vector3 | Translation [get, set] |
Get/set the conceptual translation axis from this matrix. | |
Vector3 | Scale [get] |
Calculate the per axis scaling of this matrix. | |
Matrix4 | Transposed [get] |
Return the transpose of this matrix. | |
Matrix4 | Inverse [get] |
Get the inverse of this matrix. | |
Matrix4 | RigidBodyInverse [get] |
Get the inverse of a rigid body matrix (no skew or scaling). |
A row major 4x4 transformation matrix.
The matrix is laid out as follows:
| m00 m01 m02 m03 | | 0 1 2 3 | | xx yx zx tx | M = | m10 m11 m12 m13 | = | 4 5 6 7 | = | xy yy zy ty | | m20 m21 m22 m23 | | 8 9 10 11 | | xz yz zz tz | | m30 m31 m32 m33 | | 12 13 14 15 | | 0 0 0 1 |
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. Finally, (tx, ty, tz) is the translation.
static Matrix4 Tes::Maths::Matrix4::All | ( | float | val | ) | [inline, static] |
Create a matrix with all components set to val .
val | The value to assign to each component. |
void Tes::Maths::Matrix4::ApplyScaling | ( | Vector3 | scaling | ) | [inline] |
Scales the matrix basis vectors.
The translation column is left unmodified.
scaling | Per axis scaling. Each coordinate corresponds to a column of the matrix. |
Vector3 Tes::Maths::Matrix4::GetAxis | ( | int | index | ) | [inline] |
Requests an axis or column from the matrix, dropping the last row.
A Vector4 class is need to properly extract the whole column.
index | The axis/column index [0, 3] |
static Matrix4 Tes::Maths::Matrix4::IdentityMatrix | ( | ) | [inline, static] |
The 4x4 identity matrix.
void Tes::Maths::Matrix4::InitLookAt | ( | Vector3 | eye, |
Vector3 | target, | ||
Vector3 | axisUp, | ||
int | forwardAxisIndex = 1 , |
||
int | upAxisIndex = 2 |
||
) | [inline] |
Initialise this matrix as a model or camera matrix.
LookAt(Vector3, Vector3, Vector3, int, int).
eye | The position of the eye/camera. |
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 . |
void Tes::Maths::Matrix4::InitRotation | ( | float | angleX, |
float | angleY, | ||
float | angleZ | ||
) | [inline] |
Initialise this matrix from the given Euler angles.
angleX | The rotation around the X axis (radians). |
angleY | The rotation around the Y axis (radians). |
angleZ | The rotation around the Z axis (radians). |
void Tes::Maths::Matrix4::InitRotationTranslation | ( | float | angleX, |
float | angleY, | ||
float | angleZ, | ||
Vector3 | trans | ||
) | [inline] |
Initialise this matrix from the given Euler angles and translation.
angleX | The rotation around the X axis (radians). |
angleY | The rotation around the Y axis (radians). |
angleZ | The rotation around the Z axis (radians). |
trans | The translation component for matrix. |
void Tes::Maths::Matrix4::InitRotationX | ( | float | angle | ) | [inline] |
Sets this matrix to a rotation matrix around the X axis.
angle | The rotation angle (radians) |
void Tes::Maths::Matrix4::InitRotationY | ( | float | angle | ) | [inline] |
Sets this matrix to a rotation matrix around the Y axis.
angle | The rotation angle (radians) |
void Tes::Maths::Matrix4::InitRotationZ | ( | float | angle | ) | [inline] |
Sets this matrix to a rotation matrix around the Z axis.
angle | The rotation angle (radians) |
void Tes::Maths::Matrix4::InitScaling | ( | Vector3 | scale | ) | [inline] |
Initialise this matrix as a scaling matrix.
scale | The scaling factor. Each coordinate corresponds to one of the first three columns of the matrix. |
void Tes::Maths::Matrix4::InitTranslationMatrix | ( | Vector3 | trans | ) | [inline] |
Initialise a translation matrix, no rotation or scale.
trans | The translation to apply. |
void Tes::Maths::Matrix4::Invert | ( | ) | [inline] |
Inverse this matrix.
Undefined behaviour for singular matrices.
static Matrix4 Tes::Maths::Matrix4::LookAt | ( | Vector3 | eye, |
Vector3 | target, | ||
Vector3 | axisUp, | ||
int | forwardAxisIndex = 1 , |
||
int | upAxisIndex = 2 |
||
) | [inline, 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.
eye | The position of the eye/camera. |
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 . |
Calculates the matrix product of two 4x4 matrices.
Conceptually, when the resulting matrix transforms a vector, the matrix b is applied first, then a .
a | A matrix operand. |
b | A matrix operand. |
Calculates the transformation Av
.
a | The transformation matrix. |
v | The vector to transform. |
Av
where A
is this matrix and v
is the vector argument.Vector3 Tes::Maths::Matrix4::RemoveScale | ( | ) | [inline] |
Removes scaling from the matrix basis vectors.
void Tes::Maths::Matrix4::RigidBodyInvert | ( | ) | [inline] |
Calculate the inverse of a rigid body matrix (no skew or scaling).
Performs a matrix transpose and negates the translation.
Transforms the vector v by the rotation component of this matrix.
No translation is applied.
v | The vector to rotate. |
FIXME: remove scaling effects.
static Matrix4 Tes::Maths::Matrix4::Rotation | ( | float | angleX, |
float | angleY, | ||
float | angleZ | ||
) | [inline, static] |
Build a rotation matrix from the given Euler angles.
angleX | The rotation around the X axis (radians). |
angleY | The rotation around the Y axis (radians). |
angleZ | The rotation around the Z axis (radians). |
static Matrix4 Tes::Maths::Matrix4::RotationTranslation | ( | float | angleX, |
float | angleY, | ||
float | angleZ, | ||
Vector3 | trans | ||
) | [inline, static] |
Build a transformation matrix from the given Euler angles and translation.
angleX | The rotation around the X axis (radians). |
angleY | The rotation around the Y axis (radians). |
angleZ | The rotation around the Z axis (radians). |
trans | The translation component for matrix. |
static Matrix4 Tes::Maths::Matrix4::RotationX | ( | float | angle | ) | [inline, static] |
Builds a rotation matrix around the X axis.
angle | The rotation angle (radians) |
static Matrix4 Tes::Maths::Matrix4::RotationY | ( | float | angle | ) | [inline, static] |
Sets this matrix to a rotation matrix around the Y axis.
angle | The rotation angle (radians) |
static Matrix4 Tes::Maths::Matrix4::RotationZ | ( | float | angle | ) | [inline, static] |
Sets this matrix to a rotation matrix around the Z axis.
angle | The rotation angle (radians) |
Initialise a scaling matrix.
scale | The scaling factor. Each coordinate corresponds to a column of the matrix. |
void Tes::Maths::Matrix4::SetAxis | ( | int | index, |
Vector3 | axis | ||
) | [inline] |
Set an axis or column from the matrix.
The last row is set to either zero for columns [0, 2] and 1 for column 3. A Vector4 class is need to properly set the whole column.
index | The axis/column index [0, 3] |
axis | The axis value. |
Apply this transformation to the vector v .
v | The vector to transform. |
Av
where A
is this matrix and v
is the vector argument.Create a translation matrix, no rotation or scale.
trans | The translation to apply. |
Vector3 Tes::Maths::Matrix4::AxisX [get, set] |
Get/set the conceptual X axis from this matrix.
This equates to column 0.
Vector3 Tes::Maths::Matrix4::AxisY [get, set] |
Get/set the conceptual Y axis from this matrix.
This equates to column 1.
Vector3 Tes::Maths::Matrix4::AxisZ [get, set] |
Get/set the conceptual Z axis from this matrix.
This equates to column 2.
float Tes::Maths::Matrix4::Determinant [get] |
Calculate the determinant of this matrix.
Not a cheap operation.
Matrix4 Tes::Maths::Matrix4::Inverse [get] |
Get the inverse of this matrix.
Undefined behaviour for singular matrices.
Matrix4 Tes::Maths::Matrix4::RigidBodyInverse [get] |
Get the inverse of a rigid body matrix (no skew or scaling).
Performs a matrix transpose and negates the translation.
float Tes::Maths::Matrix4::this[int index] [get, set] |
Indexing accessor across the range [0, 15].
See class documentation on the matrix layout.
index | The component index [0, 15]. |
IndexOutOfRangeException | Thrown when index is out of range. |
float Tes::Maths::Matrix4::this[int r, int c] [get, set] |
Row/column indexing accessor.
Valid row and column ranges are: [0, 3].
See class documentation on the matrix layout.
r | The row index [0, 3]. |
c | The column index [0, 3]. |
IndexOutOfRangeException | Thrown when r or c are out of range. |
Vector3 Tes::Maths::Matrix4::Translation [get, set] |
Get/set the conceptual translation axis from this matrix.
This equates to column 3.