C4 Engine
C4 Engine API Documentation

class Matrix4D

Defined in:  TSMatrix4D.h
The Matrix4D class encapsulates a 4 × 4 matrix.
Definition

class Matrix4D : public Mat4D<TypeMatrix4D>

Member Functions
Matrix4D::Set Sets all 16 entries of a matrix.
Matrix4D::SetIdentity Sets a matrix to the 4 × 4 identity matrix.
Constructor

Matrix4D();

Matrix4D(float n00, float n01, float n02, float n03, float n10, float n11, float n12, float n13,

float n20, float n21, float n22, float n23, float n30, float n31, float n32, float n33);

Matrix4D(const Vector4D& a, const Vector4D& b, const Vector4D& c, const Vector4D& d);

Parameters
nij The value of the entry residing in row i and column j.
a The values of the entries residing in first column.
b The values of the entries residing in second column.
c The values of the entries residing in third column.
d The values of the entries residing in fourth column.
Description
The Matrix4D class is used to store a 4 × 4 matrix. The entries of the matrix are accessed using the () operator with two indexes specifying the row and column of an entry.

The default constructor leaves the entries of the matrix undefined. If the 16 entries are supplied, then the nij parameter specifies the entry in the i-th row and j-th column. If the matrix is constructed using the four vectors a, b, c, and d, then these vectors initialize the four columns of the matrix.
Overloaded Operators
floatoperator ()(machine i, machine j); Returns a reference to the entry in the i-th row and j-th column. Both i and j must be 0, 1, 2, or 3.
const floatoperator ()(machine i, machine j) const; Returns a constant reference to the entry in the i-th row and j-th column. Both i and j must be 0, 1, 2, or 3.
Vector4D& operator [](machine j); Returns a reference to the j-th column of a matrix. j must be 0, 1, 2, or 3.
const Vector4D& operator [](machine j) const; Returns a constant reference to the j-th column of a matrix. j must be 0, 1, 2, or 3.
Matrix4D& operator =(const Matrix3D& m); Assigns the entries of m to the upper-left 3 × 3 portion of a matrix and assigns the entries of the identity matrix to the fourth row and fourth column.
Matrix4D& operator *=(const Matrix4D& m); Multiplies by the matrix m.
Matrix4D& operator *=(const Matrix3D& m); Multiplies by the matrix m. The entries of the fourth row and fourth column of m are assumed to be those of the identity matrix.
Nonmember Operations
Matrix4D operator *(const Matrix4D& m1, const Matrix4D& m2); Returns the product of the matrices m1 and m2.
Matrix4D operator *(const Matrix4D& m1, const Matrix3D& m2); Returns the product of the matrices m1 and m2. The entries of the fourth row and fourth column of m2 are assumed to be those of the identity matrix.
Vector4D operator *(const Matrix4D& m, const Vector4D& v); Returns the product of the matrix m and the column vector v.
Antivector4D operator *(const Antivector4D& v, const Matrix4D& m); Returns the product of the row antivector v and the matrix m.
Vector4D operator *(const Matrix4D& m, const Vector3D& v); Returns the product of the matrix m and the column vector v. The w coordinate of v is assumed to be 0.
Vector4D operator *(const Vector3D& v, const Matrix4D& m); Returns the product of the row vector v and the matrix m. The w coordinate of v is assumed to be 0.
Vector4D operator *(const Matrix4D& m, const Point3D& p); Returns the product of the matrix m and the column vector p. The w coordinate of p is assumed to be 1.
Vector4D operator *(const Point3D& p, const Matrix4D& m); Returns the product of the row vector p and the matrix m. The w coordinate of p is assumed to be 1.
Vector4D operator *(const Matrix4D& m, const Vector2D& v); Returns the product of the matrix m and the column vector v. The z and w coordinates of v are assumed to be 0.
Vector4D operator *(const Vector2D& v, const Matrix4D& m); Returns the product of the row vector v and the matrix m. The z and w coordinates of v are assumed to be 0.
Vector4D operator *(const Matrix4D& m, const Point2D& p); Returns the product of the matrix m and the column vector p. The z coordinate of p is assumed to be 0, and the w coordinate of p is assumed to be 1.
Vector4D operator *(const Point2D& p, const Matrix4D& m); Returns the product of the row vector p and the matrix m. The z coordinate of p is assumed to be 0, and the w coordinate of p is assumed to be 1.
float Determinant(const Matrix4D& m); Returns the determinant of the matrix m.
Matrix4D Inverse(const Matrix4D& m); Returns the inverse of the matrix m. If m is singular, then the result is undefined.
Matrix4D Adjugate(const Matrix4D& m); Returns the adjugate of the matrix m.
Base Classes
Mat4D Matrices use a generic base class to store their components.
See Also

Vector4D

Transform4D

Matrix3D

Vector3D

Point3D